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

NullPointerException when non-top-level element declares a new namespace and uses it #23

Closed
wonderfly opened this issue Jan 9, 2015 · 7 comments

Comments

@wonderfly
Copy link
Contributor

commented Jan 9, 2015

From yan...@google.com on August 16, 2011 07:20:56

Version of google-http-java-client (e.g. 1.5.0-beta)? 1.5.0-beta Java environment (e.g. Java 6, Android 2.3, App Engine 1.4.3)? All Describe the problem. NullPointerException when namespace is defined on a non-top-level element

Google Document List Feed produces an interior element
<app:edited xmlns:app=' http://www.w3.org/2007/app'>2011-08-09T04:38:14.017Z/app:edited The xmlns:app definition only occurs on this element, not the top-level element. When this is parsed:

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)
at org.springhaven.testing.GdataTest1.main(GdataTest1.java:166) How would you expect it to be fixed? Use a namespace stack and duplicate the namespace-addition code in Xml.java lines 228-247 at the start of each element (around line 317) to populate the stack.

Thanks to darkfoxp...@gmail.com for reporting!

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

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From timogri...@gmail.com on August 17, 2011 02:08:41

Is there any way to work around?

Regards,

@wonderfly wonderfly self-assigned this Jan 9, 2015

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From yan...@google.com on August 18, 2011 08:40:34

Yes there is a workaround. When you construct your XmlNamespaceDictionary, you should also declare the "app" namespace. For example:

XmlNamespaceDictionary namespaceDictionary = new XmlNamespaceDictionary();
namespaceDictionary.set("app", " http://www.w3.org/2007/app");

Labels: -Priority-Critical Priority-High

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From timogri...@gmail.com on August 18, 2011 09:50:25

It works! Thank you very much :)

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From yan...@google.com on August 18, 2011 11:41:33

http://codereview.appspot.com/4887049/

Status: Started

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From yan...@google.com on August 23, 2011 06:58:49

Status: Fixed

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From je...@suzanowicz.pl on August 23, 2011 22:36:58

good catch, now it works :)

@wonderfly

This comment has been minimized.

Copy link
Contributor Author

commented Jan 9, 2015

From rmis...@google.com on October 21, 2011 12:26:04

Labels: -Milestone-Version1.5.1 Milestone-Version1.5.3

@wonderfly wonderfly closed this Jan 9, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.