Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Xml Parser throws java.lang.NullPointerException #284

Closed
GoogleCodeExporter opened this issue Mar 15, 2015 · 4 comments
Closed

Using Xml Parser throws java.lang.NullPointerException #284

GoogleCodeExporter opened this issue Mar 15, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link
Collaborator

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

  • Changed state: Accepted
  • Added labels: Priority-High
  • Removed labels: Priority-Medium

@GoogleCodeExporter
Copy link
Collaborator Author

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

@GoogleCodeExporter
Copy link
Collaborator Author

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

  • Changed state: Duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant