提交 4b027fbf 编写于 作者: J Jave-Chen 提交者: dailidong

Fix SonarCloud bug “Resources should be closed” (#1667)

 #1666 Fix SonarCloud bug “Resources should be closed”
上级 1baeefc8
......@@ -55,7 +55,7 @@ public class ZooKeeperState {
public void getZookeeperInfo() {
String content = cmd("srvr");
if (StringUtils.isNotBlank(content)) {
Scanner scannerForStat = new Scanner(content);
try (Scanner scannerForStat = new Scanner(content)) {
while (scannerForStat.hasNext()) {
String line = scannerForStat.nextLine();
if (line.startsWith("Latency min/avg/max:")) {
......@@ -77,19 +77,19 @@ public class ZooKeeperState {
nodeCount = Integer.parseInt(getStringValueFromLine(line));
}
}
scannerForStat.close();
}
}
String wchsText = cmd("wchs");
if (StringUtils.isNotBlank(wchsText)) {
Scanner scannerForWchs = new Scanner(wchsText);
try (Scanner scannerForWchs = new Scanner(wchsText)) {
while (scannerForWchs.hasNext()) {
String line = scannerForWchs.nextLine();
if (line.startsWith("Total watches:")) {
watches = Integer.parseInt(getStringValueFromLine(line));
}
}
scannerForWchs.close();
}
}
String consText = cmd("cons");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册