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: more protocol fun in URL


Hi,

On Sat, 2004-07-03 at 16:25, Anthony Green wrote:
> Mark came up with the patch to not change the protocol handler when not
> required.  My addition was proper case conversion.  Ok for HEAD (and
> Classpath)?
>
> 2004-07-03  Mark Wielaard  <mark@klomp.org>
>             Anthony Green  <green@redhat.com>
> 
> 	* java/net/URL.java: (set): Convert protocol to lower case before
> 	doing anything.
> 	Only change the protocol handler if it's different.

This one didn't apply cleanly to GNU Classpath CVS. So I committed a
slightly different one (attached). I'll try to merge java/net/URL.java
with libgcj later.

Cheers,

Mark
Index: java/net/URL.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/net/URL.java,v
retrieving revision 1.32
diff -u -r1.32 URL.java
--- java/net/URL.java	4 Jul 2004 12:02:40 -0000	1.32
+++ java/net/URL.java	4 Jul 2004 12:18:57 -0000
@@ -703,14 +703,17 @@
   protected void set(String protocol, String host, int port, String file,
                      String ref)
   {
-    URLStreamHandler protocolHandler = getURLStreamHandler(protocol);
+    URLStreamHandler protocolHandler = null;
+    protocol = protocol.toLowerCase();
+    if (! this.protocol.equals(protocol))
+      protocolHandler = getURLStreamHandler(protocol);
     
     // It is an hidden feature of the JDK. If the protocol does not exist,
     // we keep the previously initialized protocol.
     if (protocolHandler != null)
       {
-        this.ph = protocolHandler;
-        this.protocol = protocol.toLowerCase();
+	this.ph = protocolHandler;
+	this.protocol = protocol;
       }
     this.authority = "";
     this.port = port;
@@ -746,14 +749,17 @@
   protected void set(String protocol, String host, int port, String authority,
                      String userInfo, String path, String query, String ref)
   {
-    URLStreamHandler protocolHandler = getURLStreamHandler(protocol);
+    URLStreamHandler protocolHandler = null;
+    protocol = protocol.toLowerCase();
+    if (! this.protocol.equals(protocol))
+      protocolHandler = getURLStreamHandler(protocol);
     
     // It is an hidden feature of the JDK. If the protocol does not exist,
     // we keep the previously initialized protocol.
     if (protocolHandler != null)
       {
-        this.ph = protocolHandler;
-        this.protocol = protocol.toLowerCase();
+	this.ph = protocolHandler;
+	this.protocol = protocol;
       }
     this.host = host;
     this.userInfo = userInfo;

Attachment: signature.asc
Description: This is a digitally signed message part


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