From f0b1cb11d0734a09aa8028e8e82b5409e3322c7f Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:44:47 +0000 Subject: [PATCH] Modernize and secure temp file creation --- .../java/stirling/software/common/util/FileToPdfTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/common/src/test/java/stirling/software/common/util/FileToPdfTest.java b/app/common/src/test/java/stirling/software/common/util/FileToPdfTest.java index a3df86aee..d939d0a1f 100644 --- a/app/common/src/test/java/stirling/software/common/util/FileToPdfTest.java +++ b/app/common/src/test/java/stirling/software/common/util/FileToPdfTest.java @@ -1,5 +1,6 @@ package stirling.software.common.util; +import java.nio.file.Files; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -47,8 +48,8 @@ public class FileToPdfTest { // Mock the temp file creation to return real temp files try { when(tempFileManager.createTempFile(anyString())) - .thenReturn(File.createTempFile("test", ".pdf")) - .thenReturn(File.createTempFile("test", ".html")); + .thenReturn(Files.createTempFile("test", ".pdf").toFile()) + .thenReturn(Files.createTempFile("test", ".html").toFile()); } catch (IOException e) { throw new RuntimeException(e); }