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:
Brian Burkhalter 2021-03-23 16:03:59 +00:00
parent e9321cdc41
commit 8fa34e4043
6 changed files with 78 additions and 14 deletions

View file

@ -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.
*
* 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
* specified, or the array contains an attribute that 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
* If an I/O error occurs
* @throws SecurityException
@ -319,6 +325,12 @@ public abstract class FileChannel
* If the {@code path} is associated with a provider that does not
* support creating file channels, or an unsupported open option 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>(<a href="../file/package-summary.html#optspecex">optional
* specific exception</a>)</i>
* @throws IOException
* If an I/O error occurs
* @throws SecurityException