8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar
authorjoehw
Wed, 11 Jan 2017 13:08:45 -0800
changeset 43127 33b8f6646c21
parent 43126 26c4004e8cc0
child 43128 ab25a1c23fef
8171243: CatalogManager.catalogResolver throws FileSystemNotFoundException with jar Reviewed-by: rriggs, dfuchs, lancea, alanb
jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java
jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java	Tue Jan 10 22:15:54 2017 +0300
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/xml/XmlUtil.java	Wed Jan 11 13:08:45 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -33,6 +33,7 @@
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 import java.lang.reflect.Method;
+import java.net.URI;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -332,13 +333,13 @@
      * (com.sun.org.apache.xml.internal) for modular runtime.
      */
     private static EntityResolver createCatalogResolver(ArrayList<URL> urls) throws Exception {
-        // Prepare array of catalog paths
-        String[] paths = urls.stream()
-                             .map(u -> u.toExternalForm())
-                             .toArray(c -> new String[c]);
+        // Prepare array of catalog URIs
+        URI[] uris = urls.stream()
+                             .map(u -> URI.create(u.toExternalForm()))
+                             .toArray(URI[]::new);
 
         //Create CatalogResolver with new JDK9+ API
-        return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, paths);
+        return (EntityResolver) CatalogManager.catalogResolver(catalogFeatures, uris);
     }
 
     // Cache CatalogFeatures instance for future usages.
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java	Tue Jan 10 22:15:54 2017 +0300
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java	Wed Jan 11 13:08:45 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -777,13 +777,13 @@
      * Adds a new catalog file.
      */
     public void addCatalog(File catalogFile) throws IOException {
-        String newUrl = catalogFile.getPath();
+        URI newUrl = catalogFile.toURI();
         if (!catalogUrls.contains(newUrl)) {
             catalogUrls.add(newUrl);
         }
         try {
             entityResolver = CatalogManager.catalogResolver(catalogFeatures,
-                                catalogUrls.toArray(new String[0]));
+                                catalogUrls.stream().toArray(URI[]::new));
         } catch (Exception ex) {
             entityResolver = null;
         }
@@ -791,7 +791,7 @@
 
     // Since javax.xml.catalog is unmodifiable we need to track catalog
     // URLs added and create new catalog each time addCatalog is called
-    private final ArrayList<String> catalogUrls = new ArrayList<String>();
+    private final ArrayList<URI> catalogUrls = new ArrayList<>();
 
     // Cache CatalogFeatures instance for future usages.
     // Resolve feature is set to "continue" value for backward compatibility.