mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +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
|
@ -209,8 +209,8 @@ public abstract class AsynchronousFileChannel
|
||||||
* FileAttribute file-attributes} to set atomically when creating the file.
|
* FileAttribute file-attributes} to set atomically when creating the file.
|
||||||
*
|
*
|
||||||
* <p> The new channel is created by invoking the {@link
|
* <p> The new channel is created by invoking the {@link
|
||||||
* FileSystemProvider#newFileChannel newFileChannel} method on the
|
* FileSystemProvider#newAsynchronousFileChannel newAsynchronousFileChannel}
|
||||||
* provider that created the {@code Path}.
|
* method on the provider that created the {@code Path}.
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* The path of the file to open or create
|
* The path of the file to open or create
|
||||||
|
@ -232,6 +232,12 @@ public abstract class AsynchronousFileChannel
|
||||||
* support creating asynchronous file channels, or an unsupported
|
* support creating asynchronous file channels, or an unsupported
|
||||||
* open option is specified, or the array contains an attribute that
|
* open option is specified, or the array contains an attribute that
|
||||||
* cannot be set atomically when creating the file
|
* cannot be set atomically when creating the file
|
||||||
|
* @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>(<a href="../file/package-summary.html#optspecex">optional
|
||||||
|
* specific exception</a>)</i>
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* If an I/O error occurs
|
* If an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
@ -287,6 +293,12 @@ public abstract class AsynchronousFileChannel
|
||||||
* If the {@code file} is associated with a provider that does not
|
* If the {@code file} is associated with a provider that does not
|
||||||
* support creating file channels, or an unsupported open option is
|
* support creating file channels, or an unsupported open option is
|
||||||
* specified
|
* 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>(<a href="../file/package-summary.html#optspecex">optional
|
||||||
|
* specific exception</a>)</i>
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* If an I/O error occurs
|
* If an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -270,6 +270,12 @@ public abstract class FileChannel
|
||||||
* support creating file channels, or an unsupported open option is
|
* support creating file channels, or an unsupported open option is
|
||||||
* specified, or the array contains an attribute that cannot be set
|
* specified, or the array contains an attribute that cannot be set
|
||||||
* atomically when creating the file
|
* atomically when creating the file
|
||||||
|
* @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>(<a href="../file/package-summary.html#optspecex">optional
|
||||||
|
* specific exception</a>)</i>
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* If an I/O error occurs
|
* If an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
@ -319,6 +325,12 @@ public abstract class FileChannel
|
||||||
* If the {@code path} is associated with a provider that does not
|
* If the {@code path} is associated with a provider that does not
|
||||||
* support creating file channels, or an unsupported open option is
|
* support creating file channels, or an unsupported open option is
|
||||||
* specified
|
* 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>(<a href="../file/package-summary.html#optspecex">optional
|
||||||
|
* specific exception</a>)</i>
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* If an I/O error occurs
|
* If an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
|
|
@ -208,6 +208,10 @@ public final class Files {
|
||||||
* if {@code options} contains an invalid combination of options
|
* if {@code options} contains an invalid combination of options
|
||||||
* @throws UnsupportedOperationException
|
* @throws UnsupportedOperationException
|
||||||
* if an unsupported option is specified
|
* 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
|
* @throws IOException
|
||||||
* if an I/O error occurs
|
* if an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
@ -349,9 +353,10 @@ public final class Files {
|
||||||
* if an unsupported open option is specified or the array contains
|
* if an unsupported open option is specified or the array contains
|
||||||
* attributes that cannot be set atomically when creating the file
|
* attributes that cannot be set atomically when creating the file
|
||||||
* @throws FileAlreadyExistsException
|
* @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
|
* 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
|
* @throws IOException
|
||||||
* if an I/O error occurs
|
* if an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
@ -395,9 +400,10 @@ public final class Files {
|
||||||
* @throws UnsupportedOperationException
|
* @throws UnsupportedOperationException
|
||||||
* if an unsupported open option is specified
|
* if an unsupported open option is specified
|
||||||
* @throws FileAlreadyExistsException
|
* @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
|
* 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
|
* @throws IOException
|
||||||
* if an I/O error occurs
|
* if an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
@ -637,7 +643,7 @@ public final class Files {
|
||||||
* if the array contains an attribute that cannot be set atomically
|
* if the array contains an attribute that cannot be set atomically
|
||||||
* when creating the file
|
* when creating the file
|
||||||
* @throws FileAlreadyExistsException
|
* @throws FileAlreadyExistsException
|
||||||
* if a file of that name already exists
|
* If a file of that name already exists
|
||||||
* <i>(optional specific exception)</i>
|
* <i>(optional specific exception)</i>
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if an I/O error occurs or the parent directory does not exist
|
* 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
|
* if an I/O error occurs opening or creating the file
|
||||||
* @throws UnsupportedOperationException
|
* @throws UnsupportedOperationException
|
||||||
* if an unsupported option is specified
|
* 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
|
* @throws SecurityException
|
||||||
* In the case of the default provider, and a security manager is
|
* In the case of the default provider, and a security manager is
|
||||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
* 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
|
* if an I/O error occurs opening or creating the file
|
||||||
* @throws UnsupportedOperationException
|
* @throws UnsupportedOperationException
|
||||||
* if an unsupported option is specified
|
* 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
|
* @throws SecurityException
|
||||||
* In the case of the default provider, and a security manager is
|
* In the case of the default provider, and a security manager is
|
||||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
* 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
|
* if an I/O error occurs writing to or creating the file
|
||||||
* @throws UnsupportedOperationException
|
* @throws UnsupportedOperationException
|
||||||
* if an unsupported option is specified
|
* 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
|
* @throws SecurityException
|
||||||
* In the case of the default provider, and a security manager is
|
* In the case of the default provider, and a security manager is
|
||||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||||
|
@ -3542,6 +3560,10 @@ public final class Files {
|
||||||
* text cannot be encoded using the specified charset
|
* text cannot be encoded using the specified charset
|
||||||
* @throws UnsupportedOperationException
|
* @throws UnsupportedOperationException
|
||||||
* if an unsupported option is specified
|
* 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
|
* @throws SecurityException
|
||||||
* In the case of the default provider, and a security manager is
|
* In the case of the default provider, and a security manager is
|
||||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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,
|
* provider} with a parameter that is an object created by another provider,
|
||||||
* will throw {@link java.nio.file.ProviderMismatchException}. </p>
|
* 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
|
* 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
|
* 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
|
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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
|
* if an unsupported option is specified
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if an I/O error occurs
|
* 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
|
* @throws SecurityException
|
||||||
* In the case of the default provider, and a security manager is
|
* In the case of the default provider, and a security manager is
|
||||||
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
* installed, the {@link SecurityManager#checkWrite(String) checkWrite}
|
||||||
|
@ -507,6 +511,11 @@ public abstract class FileSystemProvider {
|
||||||
* @throws UnsupportedOperationException
|
* @throws UnsupportedOperationException
|
||||||
* If this provider that does not support creating file channels,
|
* If this provider that does not support creating file channels,
|
||||||
* or an unsupported open option or file attribute is specified
|
* 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
|
* @throws IOException
|
||||||
* If an I/O error occurs
|
* If an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
@ -555,6 +564,11 @@ public abstract class FileSystemProvider {
|
||||||
* If this provider that does not support creating asynchronous file
|
* If this provider that does not support creating asynchronous file
|
||||||
* channels, or an unsupported open option or file attribute is
|
* channels, or an unsupported open option or file attribute is
|
||||||
* specified
|
* 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
|
* @throws IOException
|
||||||
* If an I/O error occurs
|
* If an I/O error occurs
|
||||||
* @throws SecurityException
|
* @throws SecurityException
|
||||||
|
@ -594,8 +608,9 @@ public abstract class FileSystemProvider {
|
||||||
* if an unsupported open option is specified or the array contains
|
* if an unsupported open option is specified or the array contains
|
||||||
* attributes that cannot be set atomically when creating the file
|
* attributes that cannot be set atomically when creating the file
|
||||||
* @throws FileAlreadyExistsException
|
* @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
|
* StandardOpenOption#CREATE_NEW CREATE_NEW} option is specified
|
||||||
|
* and the file is being opened for writing
|
||||||
* <i>(optional specific exception)</i>
|
* <i>(optional specific exception)</i>
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* if an I/O error occurs
|
* 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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
|
* <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
|
* 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
|
* @since 1.7
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue