You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "splett2 (via GitHub)" <gi...@apache.org> on 2023/05/02 01:41:20 UTC

[GitHub] [kafka] splett2 commented on a diff in pull request #13655: MINOR: Reduce number of threads created for integration test brokers

splett2 commented on code in PR #13655:
URL: https://github.com/apache/kafka/pull/13655#discussion_r1182012620


##########
clients/src/test/java/org/apache/kafka/test/TestUtils.java:
##########
@@ -150,17 +150,6 @@ public static String randomString(final int len) {
     public static File tempFile(final String prefix, final String suffix) throws IOException {
         final File file = Files.createTempFile(prefix, suffix).toFile();
         file.deleteOnExit();
-
-        // Note that we don't use Exit.addShutdownHook here because it allows for the possibility of accidently
-        // overriding the behaviour of this hook leading to leaked files.
-        Runtime.getRuntime().addShutdownHook(KafkaThread.nonDaemon("delete-temp-file-shutdown-hook", () -> {
-            try {
-                Utils.delete(file);
-            } catch (IOException e) {
-                log.error("Error deleting {}", file.getAbsolutePath(), e);
-            }
-        }));

Review Comment:
   For temp files this extra thread does not seem necessary. `file.deleteOnExit` already registers a shutdown hook.



-- 
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-unsubscribe@kafka.apache.org

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