{ "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

\r\n

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\n
\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\n

Tested On

\r\n

TiSDK 1.6.1, Android SDK 2.1

\r\n

Associated Helpdesk Ticket

\r\n

http://support-admin.appcelerator.com/display/WEJ-65612-589

{html}", "attachment": [ { "id": "22652", "filename": "Screen Shot 2011-08-24 at 11.13.40 AM (2).png", "author": { "name": "vsingh", "key": "vsingh", "displayName": "Vikramjeet Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-24T11:14:48.000+0000", "size": 2983794, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: Throws NullPointerException when tag not found", "creator": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "160641", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "The failcase above will cause an exception even after the fix, since you can't read {{.text}} from null ( {{.item(0)}} will return null since there are no matching items.)\r\n\r\nSimpler failcase app.js:\r\n\r\n{code:title=app.js}\r\nvar xmlString = \"\";\r\nvar doc = Ti.XML.parseString(xmlString);\r\nvar elem = doc.getElementsByTagName(\"mickey\").item(0);\r\n//Titanium.Network;\r\n{code}", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-07-26T14:49:43.000+0000", "updated": "2011-07-26T14:49:43.000+0000" }, { "id": "160642", "author": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "body": "Pull request ready:\r\n\r\nhttps://github.com/appcelerator/titanium_mobile/pull/283", "updateAuthor": { "name": "billdawson", "key": "billdawson", "displayName": "Bill Dawson", "active": true, "timeZone": "Europe/Berlin" }, "created": "2011-07-26T14:50:27.000+0000", "updated": "2011-07-26T14:50:27.000+0000" }, { "id": "163886", "author": { "name": "vsingh", "key": "vsingh", "displayName": "Vikramjeet Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Test fails on iOS while using simpler test case given by Bill Dawson in above comment. Error is pasted below and also screenshot of the error is attached.\n\nTested On: \nMac OSX Lion\nTiMob: 1.8.0.v20110819142548\nTiStud: 1.0.4.201108101535\n\nDevices used:\niPhone4 4.2.10\niPad2 4.3.5\niPhone Simulator\n\nFollowing is the error:\n\n\n[DEBUG] loading: /Users/vsingh/Library/Application Support/iPhone Simulator/4.3.2/Applications/5C91A3FF-5977-4666-95E8-89A2BA7B2625/QTS.app/atestList.js, resource: atestList_js\n\n[DEBUG] loading: /Users/vsingh/Library/Application Support/iPhone Simulator/4.3.2/Applications/5C91A3FF-5977-4666-95E8-89A2BA7B2625/QTS.app/tests/ios/2968.js, resource: tests/ios/2968_js\n\n[DEBUG] loading: /Users/vsingh/Library/Application Support/iPhone Simulator/4.3.2/Applications/5C91A3FF-5977-4666-95E8-89A2BA7B2625/QTS.app/tests/xplat/3464.js, resource: tests/xplat/3464_js\n\n[ERROR] Script Error = Result of expression 'doc.getElementsByTagName(\"mickey\")' [null] is not an object. at 3464.js (line 1).", "updateAuthor": { "name": "vsingh", "key": "vsingh", "displayName": "Vikramjeet Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-24T11:14:20.000+0000", "updated": "2011-08-24T11:14:20.000+0000" }, { "id": "163887", "author": { "name": "vsingh", "key": "vsingh", "displayName": "Vikramjeet Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "attached screenshot with error", "updateAuthor": { "name": "vsingh", "key": "vsingh", "displayName": "Vikramjeet Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-24T11:14:48.000+0000", "updated": "2011-08-24T11:14:48.000+0000" }, { "id": "164017", "author": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Tested with 1.8.0.v20110819142548\nMotorola Xoom 3.2\nNexus One 2.2.2", "updateAuthor": { "name": "nhuynh", "key": "nhuynh", "displayName": "Natalie Huynh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-08-25T10:54:07.000+0000", "updated": "2011-08-25T10:54:07.000+0000" }, { "id": "171606", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Fixing labels.", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-11-05T13:40:29.000+0000", "updated": "2011-11-05T13:40:29.000+0000" } ], "maxResults": 6, "total": 6, "startAt": 0 } } }