Details
-
Sub-task
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
New
Description
Reomve setDefaultTempDir, make getDefaultTempDir always evaluate temp dir property (no lazy init as temp. dir can change over time).
Ideally, just remove the need for temp folder altogether by scanning a given number of lead stream bytes from within a resettable stream.
private static Path DEFAULT_TEMP_DIR; /** Used by test framework */ @SuppressWarnings("unused") public static void setDefaultTempDir(Path tempDir) { DEFAULT_TEMP_DIR = tempDir; } /** * Returns the default temporary directory. By default, java.io.tmpdir. If not accessible or not * available, an IOException is thrown */ static synchronized Path getDefaultTempDir() throws IOException { if (DEFAULT_TEMP_DIR == null) { // Lazy init String tempDirPath = System.getProperty("java.io.tmpdir"); if (tempDirPath == null) { throw new IOException("Java has no temporary folder property (java.io.tmpdir)?"); } Path tempDirectory = Paths.get(tempDirPath); if (!Files.isWritable(tempDirectory)) { throw new IOException( "Java's temporary folder not present or writeable?: " + tempDirectory.toAbsolutePath()); } DEFAULT_TEMP_DIR = tempDirectory; } return DEFAULT_TEMP_DIR; }