This is an automated email from the ASF dual-hosted git repository. jnioche pushed a commit to branch tempFiles in repository https://gitbox.apache.org/repos/asf/storm.git
commit b778125a17ce7497d80aea1e339f3a282aeeb65a Author: Julien Nioche <[email protected]> AuthorDate: Tue Sep 19 13:31:25 2023 +0100 Replace File.createTempFile with java.nio.file.Files.createTempFile Signed-off-by: Julien Nioche <[email protected]> --- .../src/main/java/org/apache/storm/pmml/JpmmlRunnerTestTopology.java | 3 ++- .../test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java | 2 +- .../test/jvm/org/apache/storm/security/auth/AutoSSLTest.java | 2 +- .../storm/security/auth/authorizer/DRPCSimpleACLAuthorizerTest.java | 5 +++-- storm-core/src/jvm/org/apache/storm/utils/TopologySpoutLag.java | 3 ++- .../java/org/apache/storm/scheduler/utils/FileConfigLoaderTest.java | 5 +++-- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/storm-pmml-examples/src/main/java/org/apache/storm/pmml/JpmmlRunnerTestTopology.java b/examples/storm-pmml-examples/src/main/java/org/apache/storm/pmml/JpmmlRunnerTestTopology.java index 95c8160f9..95dff1590 100644 --- a/examples/storm-pmml-examples/src/main/java/org/apache/storm/pmml/JpmmlRunnerTestTopology.java +++ b/examples/storm-pmml-examples/src/main/java/org/apache/storm/pmml/JpmmlRunnerTestTopology.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.util.Arrays; import java.util.List; @@ -131,7 +132,7 @@ public class JpmmlRunnerTestTopology { private File loadExample(File file, String example) { try (InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(example)) { - file = File.createTempFile("pmml-example", ".tmp"); + file = Files.createTempFile("pmml-example", ".tmp").toFile(); IOUtils.copy(stream, new FileOutputStream(file)); } catch (IOException e) { throw new RuntimeException("Error loading example " + example, e); diff --git a/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java b/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java index 5e7e326e0..58648426e 100644 --- a/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java +++ b/storm-client/test/jvm/org/apache/storm/dependency/DependencyUploaderTest.java @@ -301,7 +301,7 @@ public class DependencyUploaderTest { } private File createTemporaryDummyFile() throws IOException { - File tempFile = File.createTempFile("tempfile", ".tmp"); + File tempFile = java.nio.file.Files.createTempFile("tempfile", ".tmp").toFile(); BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile)); bw.write("This is the temporary file content"); diff --git a/storm-client/test/jvm/org/apache/storm/security/auth/AutoSSLTest.java b/storm-client/test/jvm/org/apache/storm/security/auth/AutoSSLTest.java index 3eddffc9b..19c749d56 100644 --- a/storm-client/test/jvm/org/apache/storm/security/auth/AutoSSLTest.java +++ b/storm-client/test/jvm/org/apache/storm/security/auth/AutoSSLTest.java @@ -73,7 +73,7 @@ public class AutoSSLTest { @Test public void testpopulateCredentials() throws Exception { - File temp = File.createTempFile("tmp-autossl-test", ".txt"); + File temp = Files.createTempFile("tmp-autossl-test", ".txt").toFile(); temp.deleteOnExit(); List<String> lines = Arrays.asList("The first line", "The second line"); Files.write(temp.toPath(), lines, StandardCharsets.UTF_8); diff --git a/storm-client/test/jvm/org/apache/storm/security/auth/authorizer/DRPCSimpleACLAuthorizerTest.java b/storm-client/test/jvm/org/apache/storm/security/auth/authorizer/DRPCSimpleACLAuthorizerTest.java index 075fe810d..f439fd5cb 100644 --- a/storm-client/test/jvm/org/apache/storm/security/auth/authorizer/DRPCSimpleACLAuthorizerTest.java +++ b/storm-client/test/jvm/org/apache/storm/security/auth/authorizer/DRPCSimpleACLAuthorizerTest.java @@ -16,6 +16,7 @@ import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.nio.file.Files; import java.util.HashMap; import java.util.Map; import org.apache.storm.Config; @@ -175,7 +176,7 @@ public class DRPCSimpleACLAuthorizerTest { public void test_read_acl_no_values() throws IOException { DRPCSimpleACLAuthorizer authorizer = new DRPCSimpleACLAuthorizer(); - File tempFile = File.createTempFile("drpcacl", ".yaml"); + File tempFile = Files.createTempFile("drpcacl", ".yaml").toFile(); tempFile.deleteOnExit(); BufferedWriter writer = new BufferedWriter(new FileWriter(tempFile)); writer.write("drpc.authorizer.acl:"); @@ -197,7 +198,7 @@ public class DRPCSimpleACLAuthorizerTest { public void test_read_acl_empty_file() throws IOException { DRPCSimpleACLAuthorizer authorizer = new DRPCSimpleACLAuthorizer(); - File tempFile = File.createTempFile("drpcacl", ".yaml"); + File tempFile = Files.createTempFile("drpcacl", ".yaml").toFile(); tempFile.deleteOnExit(); authorizer.prepare(ImmutableMap diff --git a/storm-core/src/jvm/org/apache/storm/utils/TopologySpoutLag.java b/storm-core/src/jvm/org/apache/storm/utils/TopologySpoutLag.java index afffee4cb..4859552eb 100644 --- a/storm-core/src/jvm/org/apache/storm/utils/TopologySpoutLag.java +++ b/storm-core/src/jvm/org/apache/storm/utils/TopologySpoutLag.java @@ -21,6 +21,7 @@ import com.google.common.base.Strings; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -96,7 +97,7 @@ public class TopologySpoutLag { } if (!extraProperties.isEmpty()) { try { - file = File.createTempFile("kafka-consumer-extra", "props"); + file = Files.createTempFile("kafka-consumer-extra", "props").toFile(); file.deleteOnExit(); Properties properties = new Properties(); properties.putAll(extraProperties); diff --git a/storm-server/src/test/java/org/apache/storm/scheduler/utils/FileConfigLoaderTest.java b/storm-server/src/test/java/org/apache/storm/scheduler/utils/FileConfigLoaderTest.java index 30a4711ed..c89875248 100644 --- a/storm-server/src/test/java/org/apache/storm/scheduler/utils/FileConfigLoaderTest.java +++ b/storm-server/src/test/java/org/apache/storm/scheduler/utils/FileConfigLoaderTest.java @@ -14,6 +14,7 @@ package org.apache.storm.scheduler.utils; import java.io.File; import java.io.FileWriter; +import java.nio.file.Files; import java.util.HashMap; import java.util.Map; import org.apache.storm.Config; @@ -49,7 +50,7 @@ public class FileConfigLoaderTest { @Test public void testMalformedYaml() throws Exception { - File temp = File.createTempFile("FileLoader", ".yaml"); + File temp = Files.createTempFile("FileLoader", ".yaml").toFile(); temp.deleteOnExit(); FileWriter fw = new FileWriter(temp); @@ -69,7 +70,7 @@ public class FileConfigLoaderTest { @Test public void testValidFile() throws Exception { - File temp = File.createTempFile("FileLoader", ".yaml"); + File temp = Files.createTempFile("FileLoader", ".yaml").toFile(); temp.deleteOnExit(); Map<String, Integer> testMap = new HashMap<>();
