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]

Patch: File protocol handler fix



I'm checking in this obvious bug fix.  URL.getHost() may return null,
in which case this throws a NullPointerException.

2001-09-19  Anthony Green  <green@redhat.com>

	* gnu/gcj/protocol/file/Handler.java: Avoid NullPointerException
	when host is null.

Index: gnu/gcj/protocol/file/Handler.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/protocol/file/Handler.java,v
retrieving revision 1.4
diff -u -p -r1.4 Handler.java
--- Handler.java	2000/04/21 14:18:49	1.4
+++ Handler.java	2001/09/19 18:23:24
@@ -32,7 +32,8 @@ public class Handler extends URLStreamHa
   {
     // If a hostname is set, then we need to switch protocols to ftp
     // in order to transfer this from the remote host.
-    if (! url.getHost().equals(""))
+    String host = url.getHost();
+    if ((host != null) && (! host.equals("")))
       {
 	// Reset the protocol (and implicitly the handler) for this URL.
 	// Then have the URL attempt the connection again, as it will


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