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]

URL connection/handler


I noticed a few small issues when testing URL connections. I'm checking 
this patch in.

regards

Bryce.


2001-09-30  Bryce McKinlay  <bryce@waitaki.otago.ac.nz>

	* gnu/gcj/protocol/file/Connection.java (connect): Throw 
	FileNotFoundException if appropriate.
	* gnu/gcj/protocol/file/Handler.java (openConnection): Throw an 
	IOException if we got a file: url with a hostname. Comment out protocol
	switch to ftp for now.
	* java/net/URL.java (URL): Include protocol name in exception message
	when handler can't be found.

Index: gnu/gcj/protocol/file/Connection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/protocol/file/Connection.java,v
retrieving revision 1.3
diff -u -r1.3 Connection.java
--- Connection.java	2000/03/07 19:55:24	1.3
+++ Connection.java	2001/09/30 07:42:20
@@ -48,7 +48,11 @@
 
     // If not connected, then file needs to be openned.
     fileIn = new File(url.getFile());
-    connected = true;
+    
+    if (fileIn.exists())    
+      connected = true;
+    else
+      throw new FileNotFoundException("No such file or directory");
   }
 
   public InputStream getInputStream() throws IOException
Index: gnu/gcj/protocol/file/Handler.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/protocol/file/Handler.java,v
retrieving revision 1.5
diff -u -r1.5 Handler.java
--- Handler.java	2001/09/19 18:28:59	1.5
+++ Handler.java	2001/09/30 07:42:20
@@ -35,6 +35,8 @@
     String host = url.getHost();
     if ((host != null) && (! host.equals("")))
       {
+        throw new IOException("ftp protocol handler not yet implemented.");
+        /*
 	// Reset the protocol (and implicitly the handler) for this URL.
 	// Then have the URL attempt the connection again, as it will
 	// get the changed handler the next time around.
@@ -43,6 +45,7 @@
 	// Until the ftp protocol handler is written, this will cause
 	// a NullPointerException.
 	return url.openConnection();
+	*/
       }
 
     return new Connection(url);
Index: java/net/URL.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URL.java,v
retrieving revision 1.8
diff -u -r1.8 URL.java
--- URL.java	2001/09/06 22:32:54	1.8
+++ URL.java	2001/09/30 07:42:20
@@ -76,7 +76,7 @@
       this.handler = setURLStreamHandler(protocol);
 
     if (this.handler == null)
-      throw new MalformedURLException("Handler for protocol not found");
+      throw new MalformedURLException("Protocol handler not found: " + protocol);
 
     this.host = host;
 
@@ -175,7 +175,7 @@
       this.handler = setURLStreamHandler(protocol);
 
     if (this.handler == null)
-      throw new MalformedURLException("Handler for protocol not found");
+      throw new MalformedURLException("Protocol handler not found: " + protocol);
 
     // JDK 1.2 doc for parseURL specifically states that any '#' ref
     // is to be excluded by passing the 'limit' as the indexOf the '#'

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