This is the mail archive of the 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]

URLStreamHandler.toExternalForm() patch


The following patch makes sure that the port is ignored if it is zero or
smaller. Eclipse creates file URLs with an null host and zero as port
number, converts them to external form and then gets confused about the
":0" in the resulting String.
According to the comment in URLStreamHandler some implementations ignore
the port number completely if host is null or the empty String. We could
do the same, but that would not be according to spec.

2002-12-24  Mark Wielaard  <>

	* java/net/ (toExternalForm): Ignore port
	if zero or smaller.

OK to commit to branch and mainline?

Note to Jeroen: I will commit the same patch to Classpath but that might
not help you since Classpath has a
class that overrides toExternalForm(). Maybe just commenting out that
method will help in your case. Please let me know.


Index: java/net/
RCS file: /cvs/gcc/gcc/libjava/java/net/,v
retrieving revision 1.13
diff -u -r1.13
--- java/net/	22 Nov 2002 16:48:52 -0000	1.13
+++ java/net/	24 Dec 2002 18:45:39 -0000
@@ -436,7 +436,7 @@
     // 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.
-    boolean port_needed = port >= 0 && port != getDefaultPort();
+    boolean port_needed = port > 0 && port != getDefaultPort();
     if (port_needed)

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