ashishkumar50 commented on code in PR #10552:
URL: https://github.com/apache/ozone/pull/10552#discussion_r3452626367


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/utils/DiskCheckUtil.java:
##########
@@ -152,35 +155,41 @@ public boolean checkReadWrite(File storageDir,
       } catch (SyncFailedException syncEx) {
         logError(storageDir, String.format("Could not sync file %s to disk.",
             testFile.getAbsolutePath()), syncEx);
+        FileUtils.deletePathQuietly(testPath);
         return false;
       } catch (IOException ioEx) {
         String msg = ioEx.getMessage();
         if (msg != null && msg.contains(LINUX_DISK_FULL_MESSAGE)) {
           LOG.warn("Could not write file {} for volume check", 
testFile.getAbsolutePath(), ioEx);
+          FileUtils.deletePathQuietly(testPath);
           return true;
         }
         logError(storageDir, String.format("Could not write file %s " +
             "for volume check.", testFile.getAbsolutePath()), ioEx);
+        FileUtils.deletePathQuietly(testPath);
         return false;
       }
 
       // Read data back from the test file.
       byte[] readBytes = new byte[numBytesToWrite];
-      try (InputStream fis = Files.newInputStream(testFile.toPath())) {
-        int numBytesRead = fis.read(readBytes);
+      try (InputStream fis = Files.newInputStream(testPath)) {
+        int numBytesRead = IOUtils.read(fis, readBytes);
         if (numBytesRead != numBytesToWrite) {
           logError(storageDir, String.format("%d bytes written to file %s " +
                   "but %d bytes were read back.", numBytesToWrite,
               testFile.getAbsolutePath(), numBytesRead));
+          FileUtils.deletePathQuietly(testPath);
           return false;
         }
       } catch (FileNotFoundException | NoSuchFileException notFoundEx) {
         logError(storageDir, String.format("Could not find file %s " +
             "for volume check.", testFile.getAbsolutePath()), notFoundEx);
+        FileUtils.deletePathQuietly(testPath);

Review Comment:
   Makes sense, in normal scenario delete is verified.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to