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
Assignees
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@wonderfly
Copy link
Contributor

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 wonderfly added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. imported labels Jan 9, 2015
@wonderfly
Copy link
Contributor Author

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

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

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

It works! Thank you very much :)

@wonderfly
Copy link
Contributor Author

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

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

Status: Started

@wonderfly
Copy link
Contributor Author

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

Status: Fixed

@wonderfly
Copy link
Contributor Author

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

good catch, now it works :)

@wonderfly
Copy link
Contributor Author

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

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

@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 6, 2020
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this issue Aug 11, 2022
fixing install for users without gpg keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants