This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
URLStreamHandler.toExternalForm() patch
- From: Mark Wielaard <mark at klomp dot org>
- To: java-patches at gcc dot gnu dot org
- Cc: Jeroen Frijters <jeroen at sumatra dot nl>
- Date: 24 Dec 2002 20:00:37 +0100
- Subject: URLStreamHandler.toExternalForm() patch
- Organization:
Hi,
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 <mark@klomp.org>
* java/net/URLStreamHandler.java (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 gnu.java.net.protocol.file.Handler
class that overrides toExternalForm(). Maybe just commenting out that
method will help in your case. Please let me know.
Cheers,
Mark
Index: java/net/URLStreamHandler.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLStreamHandler.java,v
retrieving revision 1.13
diff -u -r1.13 URLStreamHandler.java
--- java/net/URLStreamHandler.java 22 Nov 2002 16:48:52 -0000 1.13
+++ java/net/URLStreamHandler.java 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)
sb.append(':').append(port);