Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -584,7 +585,8 @@ private static File copyLibToTempFile(
private static File createTempFile(Random rnd, JarEntry entry, String name)
throws ProgramInvocationException {
try {
final File tempFile = File.createTempFile(rnd.nextInt(Integer.MAX_VALUE) + "_", name);
final File tempFile =
Files.createTempFile(rnd.nextInt(Integer.MAX_VALUE) + "_", name).toFile();
tempFile.deleteOnExit();
return tempFile;
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ private RefCountedFile downloadToCacheFile(FileStateHandle fileHandle) {
File directory = cacheDirectories[next.getAndIncrement() % cacheDirectories.length];
File file;
try {
file = File.createTempFile(CACHE_FILE_PREFIX, null, directory);
file = Files.createTempFile(directory.toPath(), CACHE_FILE_PREFIX, null).toFile();
file.deleteOnExit();
Comment on lines +131 to +132

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rather delete the file explicitly?
I'm concerned that the number of such files to delete will accumulate in a long running JVM process

} catch (IOException e) {
ExceptionUtils.rethrow(e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

/**
* Simple example for demonstrating the use of SQL in Java.
Expand Down Expand Up @@ -91,7 +92,7 @@ public static void main(String[] args) throws Exception {

/** Creates a temporary file with the contents and returns the absolute path. */
private static String createTempFile(String contents) throws IOException {
File tempFile = File.createTempFile("orders", ".csv");
File tempFile = Files.createTempFile("orders", ".csv").toFile();
tempFile.deleteOnExit();
FileUtils.writeFileUtf8(tempFile, contents);
return tempFile.toURI().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
import java.net.URLDecoder;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -1032,7 +1033,8 @@ private ApplicationReport startAppMaster(
if (jobGraph != null) {
File tmpJobGraphFile = null;
try {
tmpJobGraphFile = File.createTempFile(appId.toString(), null);
tmpJobGraphFile = Files.createTempFile(appId.toString(), null).toFile();
tmpJobGraphFile.deleteOnExit();
try (FileOutputStream output = new FileOutputStream(tmpJobGraphFile);
ObjectOutputStream obOutput = new ObjectOutputStream(output)) {
obOutput.writeObject(jobGraph);
Expand Down Expand Up @@ -1064,7 +1066,9 @@ private ApplicationReport startAppMaster(
File tmpConfigurationFile = null;
try {
String flinkConfigFileName = GlobalConfiguration.getFlinkConfFilename();
tmpConfigurationFile = File.createTempFile(appId + "-" + flinkConfigFileName, null);
tmpConfigurationFile =
Files.createTempFile(appId + "-" + flinkConfigFileName, null).toFile();
tmpConfigurationFile.deleteOnExit();

// remove localhost bind hosts as they render production clusters unusable
removeLocalhostBindHostSetting(configuration, JobManagerOptions.BIND_HOST);
Expand Down