You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@iotdb.apache.org by GitBox <gi...@apache.org> on 2019/01/26 01:56:48 UTC

[GitHub] fanhualta commented on a change in pull request #31: Fix sonar

fanhualta commented on a change in pull request #31: Fix sonar
URL: https://github.com/apache/incubator-iotdb/pull/31#discussion_r251183199
 
 

 ##########
 File path: iotdb/src/main/java/org/apache/iotdb/db/postback/receiver/ServerServiceImpl.java
 ##########
 @@ -144,40 +157,37 @@ public String startReceiving(String md5OfSender, List<String> filePathSplit,
       if (!file.getParentFile().exists()) {
         try {
           file.getParentFile().mkdirs();
-          file.createNewFile();
+          if (file.createNewFile()) {
+            LOGGER.error("IoTDB post back receiver: cannot create file {}", file.getAbsoluteFile());
+          }
         } catch (IOException e) {
           LOGGER.error("IoTDB post back receiver: cannot make file because {}", e.getMessage());
         }
       }
-      try {
-        fos = new FileOutputStream(file, true); // append new data
+      try (FileOutputStream fos = new FileOutputStream(file, true)) {// append new data
         channel = fos.getChannel();
         channel.write(dataToReceive);
-        channel.close();
-        fos.close();
       } catch (Exception e) {
         LOGGER.error("IoTDB post back receiver: cannot write data to file because {}",
             e.getMessage());
 
 Review comment:
   I have fixed this problem

----------------------------------------------------------------
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