abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Wells <todd.we...@theplatform.com>
Subject NullPointerException when calling ClientResponse.getDocument()
Date Mon, 28 Apr 2008 21:30:04 GMT
I¹d like for the dev team to review this issue, which has turned into a
blocker for me.  I¹ve been digging into the Abdera code a bit and I suspect
this could actually be a race condition where the parser isn¹t initialized
by the time I call ClientResponse.getDocument().  I think the
NullPointerException is due to the overloaded method of getDocument()
calling parser.getOptions() when parser is null ‹ before whatever is
responsible for initializing the parser has succeeded.  The exact same call
succeeds when I run this inside of IDEA, which I suspect may be slowing
things down just enough so that I don¹t hit the race condition.  Either that
or there¹s some strange class loader issue going on here.  Because the NPE
doesn¹t occur when I¹m running in IDEA or in IDEA¹s debugger, I can¹t step
into the Abdera code and debug it.  I¹m on a gigabit LAN so my HTTP response
is getting returned very quickly, if that could in any way be contributing
to the issue.

Either way, I could really use some advice on this or I may need to abandon
Abdera altogether and roll my own client.  In this example I was actually
calling getDocument() from groovy code, but I tried encapsulating that code
in a java class, which didn¹t seem to make any difference.

The code which is generating this exception is very straightforward (this is
groovy, but I assume you can translate).  The exception occurs at the
getDocument() call.

    List<Entry> getHistoryEntriesForArtifact(String artifactName) {
        artifactName = sanitizePath(artifactName)
        def feedUri =

        def abdera = new Abdera()
        def client = new AbderaClient(abdera)
        if (proxy) {
            client.setProxy proxy.host, proxy.port.toInteger()

        def reqOptions = client.getDefaultRequestOptions()
        ClientResponse response = client.get(feedUri, reqOptions)
        if (response.getStatus() == 404) {
            throw new ArtifactNotFoundException("Couldn't find

        Document<Feed> feedDoc = response.getDocument()
        return feedDoc.getRoot().getEntries()

------ Forwarded Message
From: Todd Wells <todd.wells@theplatform.com>
Reply-To: <abdera-user@incubator.apache.org>
Date: Fri, 25 Apr 2008 15:38:01 -0700
To: <abdera-user@incubator.apache.org>
Subject: NullPointerException when calling ClientResponse.getDocument()

I¹m stumped.  I have this repeatable case where ClientResponse.getDocument()
results in a NullPointerException, even though a fully-formed atom document
was successfully retrieved.

Here¹s the weird part ‹ and sorry there are so many caveats here ‹ this is
running from inside an ant task that I¹ve written.  When I run it inside of
the debugger or IDE (while not debugging) it works just fine.  When I run it
via the command line I get the NPE every time.  I¹m routing both attempts
through an HTTP proxy (fiddler) and I can see that the HTTP request and
response are the same in both cases , but in the one case Abdera throws the
NPE.  I¹ve been poking at this for several hours now and I¹m at my wit¹s
end.  Here¹s the stack trace I¹m getting.  Any idea how I could further nail
this down?

Caused by: java.lang.NullPointerException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:226)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:754)

My best (and somewhat feeble) guess is that there¹s something different in
the class paths that is causing the difference in behavior.  What that might
be, I have no idea.

------ End of Forwarded Message

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message