This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.

Jeff

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)
+      sb.append(':').append(port);

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
inconsistent
+    // with the spec since the result of this method is spec'ed so it can
be
+    // 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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]