8242292: (fs) FileSystems.getFileSystem(URI) should throw IAE if the URI scheme is null

Reviewed-by: lancea, alanb
This commit is contained in:
Brian Burkhalter 2020-04-13 10:16:38 -07:00
parent 83a1d70f0f
commit 447d6499f1
2 changed files with 25 additions and 3 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2020, 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
@ -226,6 +226,9 @@ public final class FileSystems {
*/
public static FileSystem getFileSystem(URI uri) {
String scheme = uri.getScheme();
if (scheme == null) {
throw new IllegalArgumentException(uri.toString());
}
for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
if (scheme.equalsIgnoreCase(provider.getScheme())) {
return provider.getFileSystem(uri);