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); System.out.println("Connecting to " + url);
URLConnection connection = url.openConnection(); URLConnection connection = url.openConnection();
connection.connect(); connection.connect();
try (BufferedReader in = new BufferedReader(new InputStreamReader( try (InputStreamReader streamReader = new InputStreamReader(connection.getInputStream());
connection.getInputStream()))) { BufferedReader bufferedReader = new BufferedReader(streamReader)) {
for(String line; (line = in.readLine()) != null; ) { for(String line; (line = bufferedReader.readLine()) != null; ) {
if (line.startsWith(MARKER)) { if (line.startsWith(MARKER)) {
System.out.println(TAG.matcher(line).replaceAll("")); System.out.println(TAG.matcher(line).replaceAll(""));
} }

View File

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