[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#508643: libgcj9-0: URI.equals() fails with NullPointerException

Package: libgcj9-0
Version: 4.3.2-2
Severity: normal


import java.net.URI;

public class Test
    public static void main(String arg[])
      throws Exception
        String a = "http://example.org/path";;
        String b = "http://example.org/path?q=query";;

        URI ua = new URI(a);
        URI ub = new URI(b);

        System.out.println( ua.equals(ub) );

% javac Test.java && java Test
Exception in thread "main" java.lang.NullPointerException
   at java.net.URI.equals(URI.java:1215)
   at Test.main(Test.java:14)

I think the problem is in these lines:

    else if (!opaqueThis && !opaqueObj)
        boolean common = rawPath.equalsIgnoreCase(uriObj.getRawPath())
->        && ((rawQuery == null && uriObj.getRawQuery() == null)
->            || rawQuery.equalsIgnoreCase(uriObj.getRawQuery()));
        if (rawAuthority == null && uriObj.getRawAuthority() == null)
          return common;

In ua.rawQuery is null but ub.rawQuery is not, so the expression in the
brace evaluates to false and the righthand side gets evaluated with
dereferences ua.rawQuery and this causes the NullPointerException. I
think you have to write something like this:

          && (rawQuery == uriObj.getRawQuery()
              || (rawQuery != null
                  && rawQuery.equalsIgnoreCase(uriObj.getRawQuery())));

Bye, Jörg.

-- System Information:
Debian Release: unstable/experimental
  APT prefers unstable
  APT policy: (900, 'unstable'), (700, 'experimental')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.28-rc7
Locale: LANG=C, LC_CTYPE=C (charmap=UTF-8) (ignored: LC_ALL set to de_DE.UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libgcj9-0 depends on:
ii  gcj-4.3-base           4.3.2-2           The GNU Compiler Collection (gcj b
ii  libasound2             1.0.16-2          ALSA library
ii  libc6                  2.7-16            GNU C Library: Shared libraries
ii  libgcc1                1:4.3.2-1         GCC support library
ii  libgcj-common          1:4.3.2-2         Java runtime library (common files
ii  zlib1g                 1: compression library - runtime

Versions of packages libgcj9-0 recommends:
ii  libgcj9-0-awt                 4.3.2-2    AWT peer runtime libraries for use
ii  libgcj9-jar                   4.3.2-2    Java runtime library for use with 

Versions of packages libgcj9-0 suggests:
ii  libgcj9-dbg                   4.3.2-2    Debugging symbols for libraries pr

-- no debconf information

Attachment: signature.asc
Description: Digital signature http://en.wikipedia.org/wiki/OpenPGP

Reply to: