diff --git a/controller/src/test/java/org/jboss/as/controller/audit/FileAuditLogHandlerUnitTestCase.java b/controller/src/test/java/org/jboss/as/controller/audit/FileAuditLogHandlerUnitTestCase.java index e64b079ce0a..db54b6a1c0d 100644 --- a/controller/src/test/java/org/jboss/as/controller/audit/FileAuditLogHandlerUnitTestCase.java +++ b/controller/src/test/java/org/jboss/as/controller/audit/FileAuditLogHandlerUnitTestCase.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.IOException; +import java.nio.file.Files; import org.jboss.as.controller.services.path.PathManagerService; import org.junit.After; @@ -73,10 +74,7 @@ private void initializeHandler(boolean rotateAtStartup) { private static File createTempDir() { try { - File tempFile = File.createTempFile("test-config", ""); - if (!tempFile.delete() || !tempFile.mkdir()) { - throw new IOException("Couldn't create temp directory."); - } + File tempFile = Files.createTempDirectory("test-config").toFile(); return tempFile; } catch (Exception e) { throw new RuntimeException("Couldn't create temp directory.", e);