< prev index next >

src/java.base/share/classes/java/net/URI.java

Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb

*** 1934,1947 **** // private static void checkPath(String s, String scheme, String path) throws URISyntaxException { if (scheme != null) { ! if ((path != null) ! && ((path.length() > 0) && (path.charAt(0) != '/'))) ! throw new URISyntaxException(s, ! "Relative path in absolute URI"); } } private void appendAuthority(StringBuilder sb, String authority, --- 1934,1945 ---- // private static void checkPath(String s, String scheme, String path) throws URISyntaxException { if (scheme != null) { ! if (path != null && !path.isEmpty() && path.charAt(0) != '/') ! throw new URISyntaxException(s, "Relative path in absolute URI"); } } private void appendAuthority(StringBuilder sb, String authority,
*** 2138,2148 **** ru.host = base.host; ru.userInfo = base.userInfo; ru.port = base.port; String cp = (child.path == null) ? "" : child.path; ! if ((cp.length() > 0) && (cp.charAt(0) == '/')) { // 5.2 (5): Child path is absolute ru.path = child.path; } else { // 5.2 (6): Resolve relative path ru.path = resolvePath(base.path, cp, base.isAbsolute()); --- 2136,2146 ---- ru.host = base.host; ru.userInfo = base.userInfo; ru.port = base.port; String cp = (child.path == null) ? "" : child.path; ! if (!cp.isEmpty() && cp.charAt(0) == '/') { // 5.2 (5): Child path is absolute ru.path = child.path; } else { // 5.2 (6): Resolve relative path ru.path = resolvePath(base.path, cp, base.isAbsolute());
*** 2162,2172 **** // If the given URI's path is normal then return the URI; // o.w., return a new URI containing the normalized path. // private static URI normalize(URI u) { ! if (u.isOpaque() || (u.path == null) || (u.path.length() == 0)) return u; String np = normalize(u.path); if (np == u.path) return u; --- 2160,2170 ---- // If the given URI's path is normal then return the URI; // o.w., return a new URI containing the normalized path. // private static URI normalize(URI u) { ! if (u.isOpaque() || u.path == null || u.path.isEmpty()) return u; String np = normalize(u.path); if (np == u.path) return u;
< prev index next >