-
Bug
-
Resolution: Fixed
-
P3
-
7u40, 8, 9
FULL PRODUCT VERSION :
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) Client VM (build 25.74-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Win7 - 64 bit
A DESCRIPTION OF THE PROBLEM :
I'am trying to create a temp directory using the following code
public static File createTemporaryDirectory() {
File file = null;
try {
file =
File.createTempFile("xyz", "Directory" + System.getProperty("file.separator"));
file.delete();
file.mkdirs();
} catch (final IOException e) {
e.printStackTrace();
}
return file;
}
We want our product to be compatible with both 1.6 and 1.8 , but the above code doesnt work in 1.8 . I did some research and found that if i remove System.getProperty("file.separator") it works fine .
Since i cant debug the java library code , i want to know is there any change in the code of createTempFile ; i.e. in 1.6 it didnt took care of file separator but in 1.8 it does and that is the reason why i get the following exception
java.io.IOException: Unable to create temporary file, C:\Users\xxx\AppData\Local\Temp\xyz3408962131679677845Directory.
I know in 1.8 there is a new method introduced to createTempDirectory to create temp directory , but we want our product to be compatible with both 1.6 and 1.8 .
REGRESSION. Last worked in version 6u45
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) Client VM (build 25.74-b02, mixed mode, sharing)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Following code throws an exception
public static File createTemporaryDirectory() {
File file = null;
try {
file =
File.createTempFile("xyz", "Directory" + System.getProperty("file.separator"));
} catch (final IOException e) {
e.printStackTrace();
}
return file;
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
a new file object
ACTUAL -
java.io.IOException: Unable to create temporary file, C:\Users\xxxAppData\Local\Temp\xyz3408962131679677845Directory
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.IOException: Unable to create temporary file, C:\Users\xxx\AppData\Local\Temp\xyz3408962131679677845Directory
at java.io.File$TempDirectory.generateFile(File.java:1921)
at java.io.File.createTempFile(File.java:2010)
at java.io.File.createTempFile(File.java:2070)
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Remove System.getProperty("file.separator") from createTempFIle
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) Client VM (build 25.74-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Win7 - 64 bit
A DESCRIPTION OF THE PROBLEM :
I'am trying to create a temp directory using the following code
public static File createTemporaryDirectory() {
File file = null;
try {
file =
File.createTempFile("xyz", "Directory" + System.getProperty("file.separator"));
file.delete();
file.mkdirs();
} catch (final IOException e) {
e.printStackTrace();
}
return file;
}
We want our product to be compatible with both 1.6 and 1.8 , but the above code doesnt work in 1.8 . I did some research and found that if i remove System.getProperty("file.separator") it works fine .
Since i cant debug the java library code , i want to know is there any change in the code of createTempFile ; i.e. in 1.6 it didnt took care of file separator but in 1.8 it does and that is the reason why i get the following exception
java.io.IOException: Unable to create temporary file, C:\Users\xxx\AppData\Local\Temp\xyz3408962131679677845Directory.
I know in 1.8 there is a new method introduced to createTempDirectory to create temp directory , but we want our product to be compatible with both 1.6 and 1.8 .
REGRESSION. Last worked in version 6u45
ADDITIONAL REGRESSION INFORMATION:
java version "1.8.0_74"
Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
Java HotSpot(TM) Client VM (build 25.74-b02, mixed mode, sharing)
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Following code throws an exception
public static File createTemporaryDirectory() {
File file = null;
try {
file =
File.createTempFile("xyz", "Directory" + System.getProperty("file.separator"));
} catch (final IOException e) {
e.printStackTrace();
}
return file;
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
a new file object
ACTUAL -
java.io.IOException: Unable to create temporary file, C:\Users\xxxAppData\Local\Temp\xyz3408962131679677845Directory
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.io.IOException: Unable to create temporary file, C:\Users\xxx\AppData\Local\Temp\xyz3408962131679677845Directory
at java.io.File$TempDirectory.generateFile(File.java:1921)
at java.io.File.createTempFile(File.java:2010)
at java.io.File.createTempFile(File.java:2070)
REPRODUCIBILITY :
This bug can be reproduced always.
CUSTOMER SUBMITTED WORKAROUND :
Remove System.getProperty("file.separator") from createTempFIle