src/java.base/share/classes/java/nio/file/FileSystems.java

Print this page
rev 12534 : 8132497: (fs) FileSystems.newFileSystem(URI, ..) doesn't handle UOE thrown by provider
Summary: Handle UOEs in newFileSystem(URI,...) similarly to as done in newFileSystem(Path path, ClassLoader loader).
Reviewed-by: chegar

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2015, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -319,23 +319,29 @@
         throws IOException
     {
         String scheme = uri.getScheme();
 
         // check installed providers
-        for (FileSystemProvider provider: FileSystemProvider.installedProviders()) {
+        for (FileSystemProvider provider : FileSystemProvider.installedProviders()) {
             if (scheme.equalsIgnoreCase(provider.getScheme())) {
+                try {
                 return provider.newFileSystem(uri, env);
+                } catch (UnsupportedOperationException uoe) {
+                }
             }
         }
 
         // if not found, use service-provider loading facility
         if (loader != null) {
             ServiceLoader<FileSystemProvider> sl = ServiceLoader
                 .load(FileSystemProvider.class, loader);
-            for (FileSystemProvider provider: sl) {
+            for (FileSystemProvider provider : sl) {
                 if (scheme.equalsIgnoreCase(provider.getScheme())) {
+                    try {
                     return provider.newFileSystem(uri, env);
+                    } catch (UnsupportedOperationException uoe) {
+                    }
                 }
             }
         }
 
         throw new ProviderNotFoundException("Provider \"" + scheme + "\" not found");