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]

Re: Patch: File protocol handler fix


>>>>> "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


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