You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2019/02/25 05:45:37 UTC

[GitHub] sijie commented on a change in pull request #1958: Use automatic resource management to close streams

sijie commented on a change in pull request #1958: Use automatic resource management to close streams
URL: https://github.com/apache/bookkeeper/pull/1958#discussion_r259682729
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Cookie.java
 ##########
 @@ -217,16 +217,9 @@ public void writeToDirectory(File directory) throws IOException {
     }
 
     public void writeToFile (File versionFile) throws IOException {
-        FileOutputStream fos = new FileOutputStream(versionFile);
-        BufferedWriter bw = null;
-        try {
-            bw = new BufferedWriter(new OutputStreamWriter(fos, UTF_8));
+        try (FileOutputStream fos = new FileOutputStream(versionFile);
+             BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, UTF_8))) {
 
 Review comment:
   put this in a try block as well

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services