mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8241619: (fs) Files.newByteChannel(path, Set.of(CREATE_NEW, READ)) does not throw a FileAlreadyExistsException when the file exists
Reviewed-by: alanb
This commit is contained in:
parent
e9321cdc41
commit
8fa34e4043
6 changed files with 78 additions and 14 deletions
|
@ -208,6 +208,10 @@ public final class Files {
|
|||
* if {@code options} contains an invalid combination of options
|
||||
* @throws UnsupportedOperationException
|
||||
* if an unsupported option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
|
@ -349,9 +353,10 @@ public final class Files {
|
|||
* if an unsupported open option is specified or the array contains
|
||||
* attributes that cannot be set atomically when creating the file
|
||||
* @throws FileAlreadyExistsException
|
||||
* if a file of that name already exists and the {@link
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* and the file is being opened for writing <i>(optional specific
|
||||
* exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
|
@ -395,9 +400,10 @@ public final class Files {
|
|||
* @throws UnsupportedOperationException
|
||||
* if an unsupported open option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* if a file of that name already exists and the {@link
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* and the file is being opened for writing <i>(optional specific
|
||||
* exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws SecurityException
|
||||
|
@ -637,7 +643,7 @@ public final class Files {
|
|||
* if the array contains an attribute that cannot be set atomically
|
||||
* when creating the file
|
||||
* @throws FileAlreadyExistsException
|
||||
* if a file of that name already exists
|
||||
* If a file of that name already exists
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs or the parent directory does not exist
|
||||
|
@ -2981,6 +2987,10 @@ public final class Files {
|
|||
* if an I/O error occurs opening or creating the file
|
||||
* @throws UnsupportedOperationException
|
||||
* if an unsupported option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
|
@ -3027,6 +3037,10 @@ public final class Files {
|
|||
* if an I/O error occurs opening or creating the file
|
||||
* @throws UnsupportedOperationException
|
||||
* if an unsupported option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
|
@ -3478,6 +3492,10 @@ public final class Files {
|
|||
* if an I/O error occurs writing to or creating the file
|
||||
* @throws UnsupportedOperationException
|
||||
* if an unsupported option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
|
@ -3542,6 +3560,10 @@ public final class Files {
|
|||
* text cannot be encoded using the specified charset
|
||||
* @throws UnsupportedOperationException
|
||||
* if an unsupported option is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -103,7 +103,7 @@
|
|||
* provider} with a parameter that is an object created by another provider,
|
||||
* will throw {@link java.nio.file.ProviderMismatchException}. </p>
|
||||
*
|
||||
* <h2>Optional Specific Exceptions</h2>
|
||||
* <h2><a id="optspecex">Optional Specific Exceptions</a></h2>
|
||||
* Most of the methods defined by classes in this package that access the
|
||||
* file system specify that {@link java.io.IOException} be thrown when an I/O
|
||||
* error occurs. In some cases, these methods define specific I/O exceptions
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -451,6 +451,10 @@ public abstract class FileSystemProvider {
|
|||
* if an unsupported option is specified
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws SecurityException
|
||||
* In the case of the default provider, and a security manager is
|
||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||
|
@ -507,6 +511,11 @@ public abstract class FileSystemProvider {
|
|||
* @throws UnsupportedOperationException
|
||||
* If this provider that does not support creating file channels,
|
||||
* or an unsupported open option or file attribute is specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* and the file is being opened for writing
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
|
@ -555,6 +564,11 @@ public abstract class FileSystemProvider {
|
|||
* If this provider that does not support creating asynchronous file
|
||||
* channels, or an unsupported open option or file attribute is
|
||||
* specified
|
||||
* @throws FileAlreadyExistsException
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* and the file is being opened for writing
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* If an I/O error occurs
|
||||
* @throws SecurityException
|
||||
|
@ -594,8 +608,9 @@ public abstract class FileSystemProvider {
|
|||
* if an unsupported open option is specified or the array contains
|
||||
* attributes that cannot be set atomically when creating the file
|
||||
* @throws FileAlreadyExistsException
|
||||
* if a file of that name already exists and the {@link
|
||||
* If a file of that name already exists and the {@link
|
||||
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||
* and the file is being opened for writing
|
||||
* <i>(optional specific exception)</i>
|
||||
* @throws IOException
|
||||
* if an I/O error occurs
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -31,7 +31,10 @@
|
|||
*
|
||||
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor
|
||||
* or method in any class or interface in this package will cause a {@link
|
||||
* java.lang.NullPointerException NullPointerException} to be thrown.
|
||||
* java.lang.NullPointerException NullPointerException} to be thrown. In some
|
||||
* cases methods which are specified to throw an {@code IOException} may throw
|
||||
* a more specific <i><a href="../package-summary.html#optspecex">optional
|
||||
* specific exception</a></i>.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue