From 750e5f903c40072c5eff86a6c66376e1f33f0e9e Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 18 Feb 2012 15:14:16 -0700 Subject: [PATCH] include leading slash in path when parsing URLs in URLStreamHandler This matches the behavior of OpenJDK's version. --- classpath/java/net/URLStreamHandler.java | 2 +- test/UrlTest.java | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/classpath/java/net/URLStreamHandler.java b/classpath/java/net/URLStreamHandler.java index 5c72deada1..e1312437b9 100644 --- a/classpath/java/net/URLStreamHandler.java +++ b/classpath/java/net/URLStreamHandler.java @@ -40,7 +40,7 @@ public abstract class URLStreamHandler { host = s.substring(0, colon); port = Integer.parseInt(s.substring(colon + 1), slash); } - s = s.substring(slash + 1); + s = s.substring(slash); } } diff --git a/test/UrlTest.java b/test/UrlTest.java index 35281b367a..244d1ec45a 100644 --- a/test/UrlTest.java +++ b/test/UrlTest.java @@ -3,7 +3,7 @@ import java.net.URL; public class UrlTest { private static String query="var1=val1&var2=val2"; - private static String path="testpath"; + private static String path="/testpath"; private static String domain="file://www.readytalk.com"; private static String file=path + "?" + query; private static URL url; @@ -15,7 +15,6 @@ public class UrlTest { private static void setupURL() throws MalformedURLException { StringBuilder builder = new StringBuilder(); builder.append(domain); - builder.append("/"); builder.append(file); url = new URL(builder.toString()); }