Patch: File protocol handler fix

Tom Tromey tromey@redhat.com
Wed Sep 26 07:10:00 GMT 2001


>>>>> "Anthony" == Anthony Green <green@redhat.com> writes:

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

Thanks.

Anthony> -    if (! url.getHost().equals(""))
Anthony> +    String host = url.getHost();
Anthony> +    if ((host != null) && (! host.equals("")))

Sometimes I see this written as:

    if (! "".equals (url.getHost ()))

This avoids the explicit check here.  Dunno if it matters, but it is a
semi-idiom.

Tom



More information about the Java-patches mailing list