Titanium JIRA Archive
Appcelerator Community (AC)

[AC-3007] Ti.XML getNamedItem on a non existing attribute throws NullPointerException on Android

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2011-08-11T04:33:53.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid, defect
ReporterRuben Fonseca
AssigneeTony Guntharp
Created2011-07-26T09:43:00.000+0000
Updated2016-03-08T07:48:02.000+0000

Description

If you have a XML node, and request a non exiting attribute, Titanium Mobile crashes on Android with NullPointerException
var node = # XML node
node.attributes.getNamedItem('foo') // <-- crash
The reason is that on this line https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/xml/src/ti/modules/titanium/xml/NamedNodeMapProxy.java#L31 you pass null to the getNodeProxy if the name doesn't exist. Then the getNodeProxy tries to call a method on it https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/xml/src/ti/modules/titanium/xml/NodeProxy.java#L59 which causes the null pointer exception

Comments

  1. Paul Dowsett 2011-08-10

    Ruben Are you able to please provide an XML file to test this with, so the core devs have everything they need to replicate it as you see it? This will also allow them to confirm their fix works correctly. Thanks
  2. Ruben Fonseca 2011-08-10

    Hi Paul. I think the bug got fixed by this ticket TIMOB-4573, specifically on this commit https://github.com/appcelerator/titanium_mobile/commit/6bcd738ce0719847c20fa4c01b26fdbe7603525a So I think you can close this ticket now. Thank you.
  3. Paul Dowsett 2011-08-11

    That's good of you to provide a follow-up. Closing, as per your request. Cheers
  4. Paul Dowsett 2011-10-07

    Closing due to inactivity.

JSON Source