{ "id": "64096", "key": "TIMOB-3464", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11362", "description": "Mobile 1.8.0 M09", "name": "Sprint 2011-30", "archived": true, "released": true, "releaseDate": "2011-08-01" }, { "id": "11331", "description": "", "name": "Release 1.8.0", "archived": true, "released": true, "releaseDate": "2011-10-31" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-11-05T13:40:46.000+0000", "created": "2011-04-15T03:45:30.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [], "versions": [ { "id": "11260", "description": "", "name": "Release 1.6.2", "archived": true, "released": true, "releaseDate": "2011-04-20" } ], "issuelinks": [ { "id": "11779", "type": { "id": "10000", "name": "Blocks", "inward": "is blocked by", "outward": "blocks" }, "outwardIssue": { "id": "78278", "key": "TIMOB-4803", "fields": { "summary": "Android: validate xml.js drillbit test and remove unnecessary bug-related comments after all pending bug pull requests have been merged.", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "7", "description": "gh.issue.story.desc", "name": "Story", "subtask": false } } } }, { "id": "12541", "type": { "id": "10001", "name": "Cloners", "inward": "is cloned into", "outward": "is cloned from" }, "inwardIssue": { "id": "79639", "key": "TIMOB-5112", "fields": { "summary": "iOS: Throws NullPointerException when tag not found", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Medium", "id": "3" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "rseagraves", "key": "rseagraves", "displayName": "Reggie Seagraves", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-11-05T13:40:46.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}
In Android, when you getElementsByTagName() and element that\r\ndoesn't exist, It throws a NPE.
\r\nnote: iOS does not throw an exception
Step 0: Notice 'bas' is not in the xmlString in the example
\r\nStep 1: Paste example code below into appi.js
\r\nStep 2: Run example
\r\nStep 3: Click 'Find Bas'
\r\nStep 4: Notice the Null Pointer Exception
\r\nvar xmlString = '<items><foo>FOO</foo><bar>BAR</bar></items>';\r\n\r\nvar window = Ti.UI.createWindow({\r\n backgroundColor: 'green'\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n title: 'Find Foo',\r\n height: 60,\r\n width: 100,\r\n top: 40\r\n});\r\nbutton.addEventListener('click', function(e){\r\n var xml = Titanium.XML.parseString(xmlString);\r\n var element = xml.getElementsByTagName(\"foo\");\r\n Ti.API.info( element.item(0).text );\r\n});\r\n\r\nvar button2 = Ti.UI.createButton({\r\n title: 'Find Bas',\r\n height: 60,\r\n width: 100,\r\n top: 140\r\n});\r\nbutton2.addEventListener('click', function(e){\r\n var xml = Titanium.XML.parseString(xmlString);\r\n var element = xml.getElementsByTagName(\"bas\");\r\n Ti.API.info( element.item(0).text );\r\n});\r\n\r\nwindow.add(button);\r\nwindow.add(button2);\r\nwindow.open();
\r\n
\r\nTiSDK 1.6.1, Android SDK 2.1
\r\n