eolivelli commented on a change in pull request #946: ISSUE #945: Enabling 
BookieShell for LocalBookKeeper
URL: https://github.com/apache/bookkeeper/pull/946#discussion_r159773847
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/util/LocalBookKeeper.java
 ##########
 @@ -316,6 +351,43 @@ static void startLocalBookiesInternal(ServerConfiguration 
conf,
         }
     }
 
+    /**
+     * Serializes the config object to the specified file in 
localBookiesConfigDir.
+     *
+     * @param localBookieConfig
+     *         config object which has to be serialized
+     * @param fileName
+     *         name of the file
+     * @throws IOException
+     */
+    private void serializeLocalBookieConfig(ServerConfiguration 
localBookieConfig, String fileName) throws IOException {
+        File localBookiesConfigDir = new 
File(localBookieConfig.getLocalBookiesConfigDirName());
+        File localBookieConfFile = new File(localBookiesConfigDir, fileName);
+        if (localBookieConfFile.exists() && !localBookieConfFile.delete()) {
+            throw new IOException(
+                    "Unable to delete the existing LocalBookieConfigFile - " + 
localBookieConfFile.getAbsolutePath());
+        }
+        if (!localBookieConfFile.createNewFile()) {
+            throw new IOException("Unable to create new File - " + 
localBookieConfFile.getAbsolutePath());
+        }
+        PrintWriter writer = new PrintWriter(localBookieConfFile);
 
 Review comment:
   You are not setting file encoding, better to explicitly use utf-8.
   
   Nit: use try-with-resources block

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to