From a50a5f39932fb5c6b1166479d56598b82471c015 Mon Sep 17 00:00:00 2001 From: Arun Gopalpuri Date: Wed, 11 Dec 2024 12:09:29 -0800 Subject: [PATCH] Ensure Files.createTempDirectory honors java.io.tmpdir system property --- .../main/java/org/opensearch/tools/launchers/Launchers.java | 4 ++-- .../java/org/opensearch/tools/launchers/TempDirectory.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/Launchers.java b/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/Launchers.java index 815615cd936b9..ff86f1e25b889 100644 --- a/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/Launchers.java +++ b/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/Launchers.java @@ -75,8 +75,8 @@ static void exit(final int status) { } @SuppressForbidden(reason = "Files#createTempDirectory(String, FileAttribute...)") - static Path createTempDirectory(final String prefix, final FileAttribute... attrs) throws IOException { - return Files.createTempDirectory(prefix, attrs); + static Path createTempDirectory(final Path rootDir, final String prefix, final FileAttribute... attrs) throws IOException { + return Files.createTempDirectory(rootDir, prefix, attrs); } } diff --git a/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/TempDirectory.java b/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/TempDirectory.java index b282e27bc0340..7de839923d7ee 100644 --- a/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/TempDirectory.java +++ b/distribution/tools/launchers/src/main/java/org/opensearch/tools/launchers/TempDirectory.java @@ -64,7 +64,7 @@ public static void main(final String[] args) throws IOException { path = Paths.get(System.getProperty("java.io.tmpdir"), "opensearch"); Files.createDirectories(path); } else { - path = Launchers.createTempDirectory("opensearch-"); + path = Launchers.createTempDirectory(Paths.get(System.getProperty("java.io.tmpdir"), "opensearch-"); } Launchers.outPrintln(path.toString()); }