java.net.URL bugs

YAMAGUCHI Yuji yamag at distribution.co.jp
Wed Mar 24 21:19:26 PST 1999


Hello, I have found another problem in URL.java.

Here is a patch that should throw MalformedURLException in
Constructor.

Index: URL.java
===================================================================
RCS file: /home/cvspublic/kaffe/libraries/javalib/java/net/URL.java,v
retrieving revision 1.11
diff -u -r1.11 URL.java
--- URL.java	1999/03/25 03:26:07	1.11
+++ URL.java	1999/03/25 05:38:26
@@ -102,6 +102,7 @@
 			file = "";
 		}
 	}
+	handler = getURLStreamHandler(protocol);
 //System.out.println("URL = " + this);
 }
 
@@ -117,6 +118,7 @@
 	this.host = host;
 	this.file = file;
 	this.port = port;
+	handler = getURLStreamHandler(protocol);
 }
 
 public URL(URL context, String spec) throws MalformedURLException {
@@ -179,7 +181,7 @@
 		return (handler);
 	}
 
-	throw new MalformedURLException("failed to find handler");
+	throw new MalformedURLException("unknown protocol: " + protocol);
 }
 
 public int hashCode() {
@@ -213,9 +215,6 @@
 
 public URLConnection openConnection() throws IOException {
 	if (conn == null) {
-		if (handler == null) {
-			handler = getURLStreamHandler(protocol);
-		}
 		conn = handler.openConnection(this);
 		conn.connect();
 	}

--
// YAMAGUCHI Yuji - yamag at distribution.co.jp -
// Freeware Distribution Services Co.,Ltd.


More information about the kaffe mailing list