divijvaidya commented on code in PR #12233:
URL: https://github.com/apache/kafka/pull/12233#discussion_r1028199478


##########
clients/src/test/java/org/apache/kafka/test/TestUtils.java:
##########
@@ -142,26 +142,40 @@ public static String randomString(final int len) {
     }
 
     /**
-     * Create an empty file in the default temporary-file directory, using 
`kafka` as the prefix and `tmp` as the
-     * suffix to generate its name.
+     * Create an empty file in the default temporary-file directory, using the 
given prefix and suffix
+     * to generate its name.
+     * @throws IOException
      */
-    public static File tempFile() throws IOException {
-        final File file = File.createTempFile("kafka", ".tmp");
+    public static File tempFile(final String prefix, final String suffix) 
throws IOException {
+        final File file = Files.createTempFile(prefix, suffix).toFile();
         file.deleteOnExit();
 
+        Exit.addShutdownHook("delete-temp-file-shutdown-hook", () -> {

Review Comment:
   @C0urante Makes sense. We should be using 
`Runtime.getRuntime().addShutdownHook` here because we don't want the Exit 
interceptors added via the tests to override this operation of cleaning up the 
files. I will file a PR to fix it.



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to