smengcl commented on code in PR #4584:
URL: https://github.com/apache/ozone/pull/4584#discussion_r1195733634


##########
hadoop-hdds/rocks-native/src/main/java/org/apache/hadoop/hdds/utils/NativeLibraryLoader.java:
##########
@@ -132,15 +134,17 @@ private Optional<File> copyResourceFromJarToTemp(final 
String libraryName)
       }
 
       // create a temporary file to copy the library to
-      final File temp = File.createTempFile(libraryName, getLibOsSuffix());
+      final File temp = File.createTempFile(libraryName, getLibOsSuffix(),
+          new File(""));
       if (!temp.exists()) {
         return Optional.empty();
       } else {
         temp.deleteOnExit();
       }
 
       Files.copy(is, temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
-      return Optional.ofNullable(temp);
+      ShutdownHookManager.get().addShutdownHook(temp::delete, 1);

Review Comment:
   At least define a class local constant like [others 
does](https://github.com/apache/ozone/blob/297c3c1eb3ffa596d187cfd1618ab82ba3cf5d4d/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java#L377).
   
   ```suggestion
         ShutdownHookManager.get().addShutdownHook(temp::delete, 
LIBRARY_SHUTDOWN_HOOK_PRIORITY);
   ```



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