From 22df7c453f8fd4497cc64960f073f1a4e66b4dce Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Tue, 22 Dec 2015 16:42:16 +0100 Subject: [PATCH] 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 | 6 +++--- .../classes/sun/nio/fs/UnixFileSystemProvider.java | 11 ++++++----- .../unix/classes/sun/nio/fs/UnixUriUtils.java | 6 +++--- .../classes/sun/nio/fs/WindowsFileSystemProvider.java | 11 ++++++----- .../windows/classes/sun/nio/fs/WindowsUriSupport.java | 6 +++--- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/io/File.java b/jdk/src/java.base/share/classes/java/io/File.java index 6137d0acd29..089171bab9e 100644 --- a/jdk/src/java.base/share/classes/java/io/File.java +++ b/jdk/src/java.base/share/classes/java/io/File.java @@ -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("")) diff --git a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java index 182a57b94c2..f161bd3e0bf 100644 --- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java +++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixFileSystemProvider.java @@ -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"); } diff --git a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java index b59ab4275ce..a0df3e3102e 100644 --- a/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java +++ b/jdk/src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java @@ -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 diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java index cf0d23fea2b..847ef1564b5 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsFileSystemProvider.java @@ -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"); } diff --git a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java index 5748bbb02af..f95a913f448 100644 --- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java +++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java @@ -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)