FULL PRODUCT VERSION :
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b134)
Java HotSpot(TM) Client VM (build 21.0-b04, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Professional Version 6.1(Build 7601:Service Pack 1)
A DESCRIPTION OF THE PROBLEM :
The createFile() method in the Files class throws NoSuchFileException if the file already exists. I think this should be FileAlreadyExistsException. This is not mentioned in the documentation for b134.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the method to create a file twice.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
FileAlreadyExistsException thrown.
ACTUAL -
NoSuchFileException is thrown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
FileSystem fileSystem = FileSystems.getDefault();
Path path = Paths.get("C:/Garbage/dir/dir1/dir2/junk.txt");
try {
Files.createDirectories(path.getParent());
Files.createFile(path);
Files.createFile(path);
} catch(NoSuchFileException e) {
System.err.println("File not created.\n" + e);
} catch(FileAlreadyExistsException e) {
System.err.println("File not created.\n" + e);
} catch(IOException e) {
System.err.println(e);
}
}
}
---------- END SOURCE ----------
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b134)
Java HotSpot(TM) Client VM (build 21.0-b04, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 Professional Version 6.1(Build 7601:Service Pack 1)
A DESCRIPTION OF THE PROBLEM :
The createFile() method in the Files class throws NoSuchFileException if the file already exists. I think this should be FileAlreadyExistsException. This is not mentioned in the documentation for b134.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Execute the method to create a file twice.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
FileAlreadyExistsException thrown.
ACTUAL -
NoSuchFileException is thrown.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
FileSystem fileSystem = FileSystems.getDefault();
Path path = Paths.get("C:/Garbage/dir/dir1/dir2/junk.txt");
try {
Files.createDirectories(path.getParent());
Files.createFile(path);
Files.createFile(path);
} catch(NoSuchFileException e) {
System.err.println("File not created.\n" + e);
} catch(FileAlreadyExistsException e) {
System.err.println("File not created.\n" + e);
} catch(IOException e) {
System.err.println(e);
}
}
}
---------- END SOURCE ----------