refactor: IO改成try resource。instanceList循环直接改成addAll
This commit is contained in:
parent
08e69a0b21
commit
4e6d8b67a2
@ -121,11 +121,8 @@ public class SystemUtils {
|
||||
|
||||
public static List<String> readClusterConf() throws IOException {
|
||||
List<String> instanceList = new ArrayList<String>();
|
||||
Reader reader = null;
|
||||
|
||||
try {
|
||||
reader = new InputStreamReader(new FileInputStream(new File(CLUSTER_CONF_FILE_PATH)),
|
||||
StandardCharsets.UTF_8);
|
||||
try(Reader reader = new InputStreamReader(new FileInputStream(new File(CLUSTER_CONF_FILE_PATH)),
|
||||
StandardCharsets.UTF_8)) {
|
||||
List<String> lines = IoUtils.readLines(reader);
|
||||
String comment = "#";
|
||||
for (String line : lines) {
|
||||
@ -142,19 +139,13 @@ public class SystemUtils {
|
||||
int multiIndex = instance.indexOf(Constants.COMMA_DIVISION);
|
||||
if (multiIndex > 0) {
|
||||
// support the format: ip1:port,ip2:port # multi inline
|
||||
for (String ins : instance.split(Constants.COMMA_DIVISION)) {
|
||||
instanceList.add(ins);
|
||||
}
|
||||
instanceList.addAll(Arrays.asList(instance.split(Constants.COMMA_DIVISION)));
|
||||
} else {
|
||||
//support the format: 192.168.71.52:8848
|
||||
instanceList.add(instance);
|
||||
}
|
||||
}
|
||||
return instanceList;
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user