matsudakazumi / google-api-java-client

Automatically exported from code.google.com/p/google-api-java-client
0 stars 0 forks source link

Using Xml Parser throws java.lang.NullPointerException #284

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-api-java-client (e.g. 1.5.0-beta)?
1.4.1-beta

Java environment (e.g. Java 6, Android 2.3, App Engine)?
App Engine

Describe the problem.
Trying to parse Xml response throws 
java.lang.NullPointerException
        at com.google.api.client.xml.Xml.getFieldName(Xml.java:513)
        at com.google.api.client.xml.Xml.parseElementInternal(Xml.java:317)
        at com.google.api.client.xml.Xml.parseElementInternal(Xml.java:454)
        at com.google.api.client.xml.Xml.parseElement(Xml.java:198)
        at com.google.api.client.http.xml.XmlHttpParser.parse(XmlHttpParser.java:72)
        at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:298)

How would you expect it to be fixed?
I have managed to change com.google.api.client.xml.Xml file and it seems to 
work for now. In my modified file line 513 (that have been throwing exception) 
is at number 514, and I have inserted the following code at line 513 

if (alias == null) alias = "";

The root element of the xml response looks like this:
<myRootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation="http://example.com" created="2011-08-29">
No inner elements declare xml namespaces.

Original issue reported on code.google.com by dsbo...@gmail.com on 29 Aug 2011 at 10:49

Attachments:

GoogleCodeExporter commented 9 years ago
I had the same issue and another work around is to add an empty string alias to 
the namespace dictionary.

XmlNamespaceDictionary namespaceDictionary = new 
XmlNamespaceDictionary().set("", ""); 

Original comment by craig2600 on 18 Oct 2011 at 11:04

GoogleCodeExporter commented 9 years ago
Stack trace looks identical to:

http://code.google.com/p/google-http-java-client/issues/detail?id=23

But it's no guarantee that it's the same issue.  We should investigate whether 
the fix for the above fixes this issue.

Can you please give us the whole XML content being parsed so we can reproduce 
it exactly?

By the way Ravi, we should release google-http-java-client 1.5.1-beta with the 
bug fix so our users can benefit from the bug fix.

Original comment by yan...@google.com on 18 Oct 2011 at 11:20

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 14 Jan 2013 at 3:31

GoogleCodeExporter commented 9 years ago

Original comment by yan...@google.com on 14 Jan 2013 at 4:08