FYI: Patch: java.net.URLStreamHandler
Michael Koch
konqueror@gmx.de
Thu Oct 30 12:50:00 GMT 2003
On Thu, Oct 30, 2003 at 01:13:14PM +0100, Michael Koch wrote:
> On Thu, Oct 30, 2003 at 01:13:07PM +1300, Bryce McKinlay wrote:
> > On Oct 30, 2003, at 11:54 AM, Mark Wielaard wrote:
> >
> > >BTW. The above example should also make the comment (that your new
> > >patch
> > >now also removes) more clear. Another solution would be to not print
> > >the
> > >port number when the host field is null, but we choose not to do this
> > >since we think that is not according to spec (even though some
> > >implementations seem to do it that way).
> >
> > If we print the port number without a host name, then (I suspect) it
> > would not be a valid URL. The best solution IMO would be to change it
> > to something like:
> >
> > if (hostName.length() == 0)
> > {
> > .. print hostname ...
> > if (port >= 0)
> > {
> > ... print port
> > }
> > }
> >
> > This way we can get rid of the comment, and match the JDK behaviour.
> >
> > (0 actually is a valid TCP port number, iirc, so I guess we should be
> > able to print it)
>
> What about the attached patch ? Does everyone agree with it ?
The patch has a little bug, it didnt accept valid port number 0.
Here is a revised patch.
Michael
-------------- next part --------------
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2311
diff -u -b -B -r1.2311 ChangeLog
--- ChangeLog 29 Oct 2003 16:17:50 -0000 1.2311
+++ ChangeLog 30 Oct 2003 12:47:33 -0000
@@ -1,3 +1,9 @@
+2003-10-30 Michael Koch <konqueror@gmx.de>
+
+ * java/net/URLStreamHandler.java
+ (toExternalForm): Add port only when hostname is present,
+ fixed port condition to allow only ports > 0.
+
2003-10-29 Sascha Brawer <brawer@dandelis.ch>
* java/awt/geom/CubicCurve2D.java (contains): Docfix for URL of embedded drawing.
Index: java/net/URLStreamHandler.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLStreamHandler.java,v
retrieving revision 1.22
diff -u -b -B -r1.22 URLStreamHandler.java
--- java/net/URLStreamHandler.java 29 Oct 2003 14:44:51 -0000 1.22
+++ java/net/URLStreamHandler.java 30 Oct 2003 12:47:34 -0000
@@ -478,11 +478,13 @@
}
if (host.length() != 0)
+ {
sb.append("//").append(host);
// Append port if port was in URL spec.
- if (port != -1)
+ if (port >= 0)
sb.append(':').append(port);
+ }
sb.append(file);
More information about the Java-patches
mailing list