This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
java/net/URLConnection.java
- From: Andrew Haley <aph at redhat dot com>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 12 Jul 2005 10:56:09 +0100
- Subject: java/net/URLConnection.java
Obvious/trivial.
You can't do that.
Andrew.
2005-07-12 Andrew Haley <aph@redhat.com>
* java/net/URLConnection.java (getContentHandler): Guard cast with
instaceof.
--- java/net/URLConnection.java 28 Sep 2004 11:02:35 -0000 1.34
+++ java/net/URLConnection.java 12 Jul 2005 09:48:57 -0000
@@ -979,17 +979,22 @@
if (contentType == null || contentType.equals(""))
return null;
- ContentHandler handler;
+ ContentHandler handler = null;
// See if a handler has been cached for this content type.
// For efficiency, if a content type has been searched for but not
// found, it will be in the hash table but as the contentType String
// instead of a ContentHandler.
- if ((handler = (ContentHandler) handlers.get(contentType)) != null)
- if (handler instanceof ContentHandler)
- return handler;
- else
- return null;
+ {
+ Object cachedHandler;
+ if ((cachedHandler = handlers.get(contentType)) != null)
+ {
+ if (cachedHandler instanceof ContentHandler)
+ return (ContentHandler)cachedHandler;
+ else
+ return null;
+ }
+ }
// If a non-default factory has been set, use it.
if (factory != null)