diff --git a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java index 5d7375f9b9470..01be80cdbfc62 100644 --- a/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java +++ b/components/camel-test/camel-test-junit5/src/main/java/org/apache/camel/test/junit5/TestSupport.java @@ -485,8 +485,9 @@ public static void recursivelyDeleteDirectory(File file) { recursivelyDeleteDirectory(child); } } - boolean success = file.delete(); - if (!success) { + try { + Files.delete(file.toPath()); + } catch (IOException e) { LOG.warn("Deletion of file: {} failed", file.getAbsolutePath()); } }