8298380: Clean up redundant array length checks in JDK code base

Reviewed-by: dholmes, amenkov, serb, vtewari
This commit is contained in:
Sergey Tsypanov 2022-12-09 12:50:55 +00:00 committed by Julian Waters
parent 33d955ad6e
commit e3c6cf8eaf
8 changed files with 37 additions and 51 deletions

View file

@ -411,13 +411,11 @@ public abstract class FileSystemProvider {
public InputStream newInputStream(Path path, OpenOption... options)
throws IOException
{
if (options.length > 0) {
for (OpenOption opt: options) {
// All OpenOption values except for APPEND and WRITE are allowed
if (opt == StandardOpenOption.APPEND ||
opt == StandardOpenOption.WRITE)
throw new UnsupportedOperationException("'" + opt + "' not allowed");
}
for (OpenOption opt : options) {
// All OpenOption values except for APPEND and WRITE are allowed
if (opt == StandardOpenOption.APPEND ||
opt == StandardOpenOption.WRITE)
throw new UnsupportedOperationException("'" + opt + "' not allowed");
}
ReadableByteChannel rbc = Files.newByteChannel(path, options);
if (rbc instanceof FileChannelImpl) {