Summary
Add @throws FileAlreadyExistsException
to the specifications of some methods in some classes in java.nio.channels.AsynchronousFileChannel
, java.nio.channels.FileChannel
, java.nio.file.Files
, and java.nio.file.spi.FileSystemProvider
which are susceptible to throwing this exception.
Problem
A number of methods in java.nio.channels.AsynchronousFileChannel
, java.nio.channels.FileChannel
, java.nio.file.Files
, and java.nio.file.spi.FileSystemProvider
will throw a FileAlreadyExistsException
if the file is being opened for appending or writing and the option java.nio.file.StandardOpenOption.CREATE_NEW
is specified.
Solution
While FileAlreadyExistsException
is an "optional specific exception," a specialized subclass of IOException
intended to convey a more precise reason for a failure than would a plain IOException
, hence not strictly required to be documented explicitly, it is in fact declared in some places but not in others. This change would add it to the specifications of those methods wherein it may occur thereby making the overall API specification more consistent.
Specification
Please refer to the attached archive specdiff-8241619.01.zip
.
- csr of
-
JDK-8241619 (fs) Files.newByteChannel(path, Set.of(CREATE_NEW, READ)) does not throw a FileAlreadyExistsException when the file exists
-
- Resolved
-