jt2594838 commented on a change in pull request #31: Fix sonar
URL: https://github.com/apache/incubator-iotdb/pull/31#discussion_r251002597
##########
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:
Another lost stack trace.
Is the use of generic class Exception necessary?
----------------------------------------------------------------
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