This is the mail archive of the
mailing list for the Java project.
Re: Patch: java.net.URLStreamHandler
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: Michael Koch <konqueror at gmx dot de>, <java-patches at gcc dot gnu dot org>
- Date: Tue, 28 Oct 2003 16:15:27 -0500 (EST)
- Subject: Re: Patch: java.net.URLStreamHandler
On Tue, 28 Oct 2003, Tom Tromey wrote:
> Michael> The attached patch fixes a mauve failure. JDK prints the port number always
> Michael> if it was present in the URL spec, even if its equal to the default port.
> Michael> This patch fixes this.
> Could you look into the history of this piece of code a little?
> I remember it going in as a bug fix at some point; I'd like to
> understand why it now seems to be incorrect.
See below. Essentaially Michael's patch will revert back to the pre-merge
behavior. IMHO the comment should also have been killed at the time of
merging with classpath.
1.14 Mon Dec 30 22:41:10 2002 UTC (9 months, 4 weeks ago) by mark:
* java/net/URLStreamHandler.java (toExternalForm): Ignore port
if zero or smaller.
- boolean port_needed = port >= 0 && port != getDefaultPort();
+ boolean port_needed = port > 0 && port != getDefaultPort();
1.13 Fri Nov 22 16:48:52 2002 UTC (11 months ago) by mark
* java/net/URLStreamHandler: Merge with Classpath.
- if (host == null)
- host = "";
- if (port >= 0 || ! (host.length() == 0))
- resStr = resStr + "//" + host + (port < 0 ? "" : ":" + port);
+ boolean port_needed = port >= 0 && port != getDefaultPort();
+ if (port_needed)
1.3 Thu Jun 3 22:29:12 1999 UTC (4 years, 4 months ago) by warrenl:
(no relevant ChangeLog)
- if (! host.equals(""))
- resStr = resStr + "//" + host;
- if (port >= 0)
- resStr = resStr + ":" + port;
+ // JDK 1.2 online doc infers that host could be null because it
+ // explicitly states that file cannot be null, but is silent on host.
+ // Note that this produces different results from JDK 1.2 as JDK 1.2
+ // ignores a non-default port if host is null or "". That is
+ // with the spec since the result of this method is spec'ed so it can
+ // used to construct a new URL that is equivalent to the original.
+ if (host == null)
+ host = "";
+ if (port >= 0 || ! (host.length() == 0))
+ resStr = resStr + "//" + host + (port < 0 ? "" : ":" + port);