HBASE-16035 Nested AutoCloseables might not all get closed (Sean Mackrory)

This commit is contained in:
tedyu 2016-06-20 16:25:50 -07:00
parent 4ca4cd856e
commit 3de0c63105
2 changed files with 6 additions and 5 deletions

View File

@ -72,9 +72,9 @@ public class LogLevel {
System.out.println("Connecting to " + url);
URLConnection connection = url.openConnection();
connection.connect();
try (BufferedReader in = new BufferedReader(new InputStreamReader(
connection.getInputStream()))) {
for(String line; (line = in.readLine()) != null; ) {
try (InputStreamReader streamReader = new InputStreamReader(connection.getInputStream());
BufferedReader bufferedReader = new BufferedReader(streamReader)) {
for(String line; (line = bufferedReader.readLine()) != null; ) {
if (line.startsWith(MARKER)) {
System.out.println(TAG.matcher(line).replaceAll(""));
}

View File

@ -124,8 +124,9 @@ public class JarFinder {
jarDir));
}
}
try (JarOutputStream zos = new JarOutputStream(new FileOutputStream(jarFile))) {
jarDir(dir, "", zos);
try (FileOutputStream fos = new FileOutputStream(jarFile);
JarOutputStream jos = new JarOutputStream(fos)) {
jarDir(dir, "", jos);
}
}