8145988: Use the raw methods of java.net.URI when possible

Reviewed-by: shade, chegar
This commit is contained in:
Claes Redestad 2015-12-22 16:42:16 +01:00
parent 7e4d56677d
commit 22df7c453f
5 changed files with 21 additions and 19 deletions

View File

@ -420,11 +420,11 @@ public class File
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(""))

View File

@ -69,15 +69,16 @@ public abstract class UnixFileSystemProvider
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");
}

View File

@ -49,11 +49,11 @@ class UnixUriUtils {
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

View File

@ -61,15 +61,16 @@ public class WindowsFileSystemProvider
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");
}

View File

@ -123,16 +123,16 @@ class WindowsUriSupport {
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)