8145988: Use the raw methods of java.net.URI when possible
authorredestad
Tue, 22 Dec 2015 16:42:16 +0100
changeset 34782 fe102f179318
parent 34781 479b1724ab80
child 34783 337afb24ec6c
child 34821 2cf888068d7a
8145988: Use the raw methods of java.net.URI when possible Reviewed-by: shade, chegar
jdk/src/java.base/share/classes/java/io/File.java
jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java
jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java
jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java
jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java
--- a/jdk/src/java.base/share/classes/java/io/File.java	Tue Dec 22 12:17:25 2015 +0000
+++ b/jdk/src/java.base/share/classes/java/io/File.java	Tue Dec 22 16:42:16 2015 +0100
@@ -420,11 +420,11 @@
         String scheme = uri.getScheme();
         if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
             throw new IllegalArgumentException("URI scheme is not \"file\"");
-        if (uri.getAuthority() != null)
+        if (uri.getRawAuthority() != null)
             throw new IllegalArgumentException("URI has an authority component");
-        if (uri.getFragment() != null)
+        if (uri.getRawFragment() != null)
             throw new IllegalArgumentException("URI has a fragment component");
-        if (uri.getQuery() != null)
+        if (uri.getRawQuery() != null)
             throw new IllegalArgumentException("URI has a query component");
         String p = uri.getPath();
         if (p.equals(""))
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java	Tue Dec 22 12:17:25 2015 +0000
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java	Tue Dec 22 16:42:16 2015 +0100
@@ -69,15 +69,16 @@
     private void checkUri(URI uri) {
         if (!uri.getScheme().equalsIgnoreCase(getScheme()))
             throw new IllegalArgumentException("URI does not match this provider");
-        if (uri.getAuthority() != null)
+        if (uri.getRawAuthority() != null)
             throw new IllegalArgumentException("Authority component present");
-        if (uri.getPath() == null)
+        String path = uri.getPath();
+        if (path == null)
             throw new IllegalArgumentException("Path component is undefined");
-        if (!uri.getPath().equals("/"))
+        if (!path.equals("/"))
             throw new IllegalArgumentException("Path component should be '/'");
-        if (uri.getQuery() != null)
+        if (uri.getRawQuery() != null)
             throw new IllegalArgumentException("Query component present");
-        if (uri.getFragment() != null)
+        if (uri.getRawFragment() != null)
             throw new IllegalArgumentException("Fragment component present");
     }
 
--- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java	Tue Dec 22 12:17:25 2015 +0000
+++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java	Tue Dec 22 16:42:16 2015 +0100
@@ -49,11 +49,11 @@
         String scheme = uri.getScheme();
         if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
             throw new IllegalArgumentException("URI scheme is not \"file\"");
-        if (uri.getAuthority() != null)
+        if (uri.getRawAuthority() != null)
             throw new IllegalArgumentException("URI has an authority component");
-        if (uri.getFragment() != null)
+        if (uri.getRawFragment() != null)
             throw new IllegalArgumentException("URI has a fragment component");
-        if (uri.getQuery() != null)
+        if (uri.getRawQuery() != null)
             throw new IllegalArgumentException("URI has a query component");
 
         // compatibility with java.io.File
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java	Tue Dec 22 12:17:25 2015 +0000
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java	Tue Dec 22 16:42:16 2015 +0100
@@ -61,15 +61,16 @@
     private void checkUri(URI uri) {
         if (!uri.getScheme().equalsIgnoreCase(getScheme()))
             throw new IllegalArgumentException("URI does not match this provider");
-        if (uri.getAuthority() != null)
+        if (uri.getRawAuthority() != null)
             throw new IllegalArgumentException("Authority component present");
-        if (uri.getPath() == null)
+        String path = uri.getPath();
+        if (path == null)
             throw new IllegalArgumentException("Path component is undefined");
-        if (!uri.getPath().equals("/"))
+        if (!path.equals("/"))
             throw new IllegalArgumentException("Path component should be '/'");
-        if (uri.getQuery() != null)
+        if (uri.getRawQuery() != null)
             throw new IllegalArgumentException("Query component present");
-        if (uri.getFragment() != null)
+        if (uri.getRawFragment() != null)
             throw new IllegalArgumentException("Fragment component present");
     }
 
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java	Tue Dec 22 12:17:25 2015 +0000
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java	Tue Dec 22 16:42:16 2015 +0100
@@ -123,16 +123,16 @@
         String scheme = uri.getScheme();
         if ((scheme == null) || !scheme.equalsIgnoreCase("file"))
             throw new IllegalArgumentException("URI scheme is not \"file\"");
-        if (uri.getFragment() != null)
+        if (uri.getRawFragment() != null)
             throw new IllegalArgumentException("URI has a fragment component");
-        if (uri.getQuery() != null)
+        if (uri.getRawQuery() != null)
             throw new IllegalArgumentException("URI has a query component");
         String path = uri.getPath();
         if (path.equals(""))
             throw new IllegalArgumentException("URI path component is empty");
 
         // UNC
-        String auth = uri.getAuthority();
+        String auth = uri.getRawAuthority();
         if (auth != null && !auth.equals("")) {
             String host = uri.getHost();
             if (host == null)