{ "id": "63308", "key": "TIMOB-2676", "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": [], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-07-26T03:12:21.000+0000", "created": "2011-04-15T03:26:43.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "httpclient", "response", "xhr" ], "versions": [], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2017-07-26T03:12:21.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": "The Android HttpClient module in 1.5.1 is unable to handle a missing entity. This is possible when encountering a 204 HTTP status code (no content).\r\n\r\nThe following is stated in the Apache HttpClient \"http://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/HttpEntity.html\" Java API doc:\r\n\r\n\"An entity that can be sent or received with an HTTP message. Entities can be found in some requests and in responses, where they are optional.\"\r\n\r\nCurrently lines 203 - 208 in TiHTTPClient.java assume that any status code less then 300 will have an entity. However this is not true. Other codes may not. This includes 204 (no content) and 201 (created).\r\n\r\nRequests made that result in these response codes will currently result in null pointer exceptions when executing line 209:\r\n\r\n{code}\r\nentity = response.getEntity();\r\nif (entity.getContentType() != null) {\r\n contentType = entity.getContentType().getValue();\r\n}\r\n{code}\r\n\r\nThe iPhone version does not appear to suffer from the same issue.", "attachment": [], "flagged": false, "summary": "Titanium Mobile Android HttpClient Unable to Handle 204 Error Code", "creator": { "name": "philip.jarrell(atgmail)", "key": "philip.jarrell(atgmail)", "displayName": "philip.jarrell (at gmail)", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "philip.jarrell(atgmail)", "key": "philip.jarrell(atgmail)", "displayName": "philip.jarrell (at gmail)", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "129179", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Assigning to Don for triage.

{html}", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:26:43.000+0000", "updated": "2011-04-15T03:26:43.000+0000" }, { "id": "367947", "author": { "name": "jalo@emtnordic.com", "key": "jalo@emtnordic.com", "displayName": "Jacob Lorenzen", "active": true, "timeZone": "Europe/Copenhagen" }, "body": "Come on.. Why hasn't this been fixed yet?\r\nReported over 4 years ago...", "updateAuthor": { "name": "jalo@emtnordic.com", "key": "jalo@emtnordic.com", "displayName": "Jacob Lorenzen", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2015-10-27T07:37:23.000+0000", "updated": "2015-10-27T07:37:23.000+0000" }, { "id": "367948", "author": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "body": "[~msamah] FYI", "updateAuthor": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2015-10-27T07:44:13.000+0000", "updated": "2015-10-27T07:44:13.000+0000" }, { "id": "367952", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~jalo@emtnordic.com] Could I help assist if you are facing this issue?\r\n\r\nIf so, are there logs or code that you can provide to help speed up the progress of this ticket. Any information would be much appreciated in fixing the issue that you are facing.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-10-27T08:01:09.000+0000", "updated": "2015-10-27T08:01:09.000+0000" }, { "id": "367955", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "For this particular ticket and that code, it has been fixed in this PR\r\nhttps://github.com/appcelerator/titanium_mobile/commit/cafb4fe6e7445043fea61bd846bdfdba8a533311", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-10-27T08:19:40.000+0000", "updated": "2015-10-27T08:19:40.000+0000" }, { "id": "367956", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "Tested with 5.0.2.GA with the following code and there is no problem\r\nTo check there is indeed no entity, run this in terminal 'curl -D - https://httpbin.org/status/204'.\r\n\r\n{code}\r\nTitanium.UI.setBackgroundColor('#000');\r\n\r\nvar win = Titanium.UI.createWindow({\r\n\ttitle : 'Title Here',\r\n\tbackgroundColor : '#fff'\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n\ttitle : \"Press Button 204\",\r\n\ttop : 100\r\n});\r\n\r\nbutton.addEventListener(\"click\", function(e) {\r\n\tvar xhr = Ti.Network.createHTTPClient({\r\n\t\tonload : function(e) {\r\n\t\t\talert(\"Received: Status = \" + this.status + \", Value = \" + this.responseText);\r\n\t\t\tTi.API.info(\"Received: Status = \" + this.status + \", Value = \" + this.responseText);\r\n\t\t},\r\n\t\tonerror : function(e) {\r\n\t\t\talert(\"Error: Status = \" + this.status + \", Value = \" + this.responseText, \" error:\" + e.error);\r\n\t\t}\r\n\t});\r\n\txhr.open(\"GET\", \"https://httpbin.org/status/204\");\r\n\txhr.send();\r\n});\r\n\r\nwin.add(button);\r\n\r\nvar button1 = Ti.UI.createButton({\r\n\ttitle : \"Press Button 201\",\r\n\ttop : 200\r\n});\r\n\r\nbutton1.addEventListener(\"click\", function(e) {\r\n\tvar xhr = Ti.Network.createHTTPClient({\r\n\t\tonload : function(e) {\r\n\t\t\talert(\"Received: Status = \" + this.status + \", Value = \" + this.responseText);\r\n\t\t\tTi.API.info(\"Received: Status = \" + this.status + \", Value = \" + this.responseText);\r\n\t\t},\r\n\t\tonerror : function(e) {\r\n\t\t\talert(\"Error: Status = \" + this.status + \", Value = \" + this.responseText, \" error:\" + e.error);\r\n\t\t}\r\n\t});\r\n\txhr.open(\"GET\", \"https://httpbin.org/status/201\");\r\n\txhr.send();\r\n});\r\n\r\nwin.add(button1);\r\n\r\nwin.open();\r\n{code}\r\n\r\nIf there is no more updates related to the ticket, I'll close this as invalid as it is not reproducible.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-10-27T08:24:27.000+0000", "updated": "2015-10-27T08:26:31.000+0000" }, { "id": "367957", "author": { "name": "jalo@emtnordic.com", "key": "jalo@emtnordic.com", "displayName": "Jacob Lorenzen", "active": true, "timeZone": "Europe/Copenhagen" }, "body": "* I use Ti.Network.createHTTPClient.\r\n* Then I call a service, which returns 204 and an empty body, which is a valid response.\r\n* This results in the following error and the \"onerror\" function on HTTPClient is called.\r\n\r\n[ERROR] TiHTTPClient: (TiHttpClient-21) [120368,593182] HTTP Error (java.lang.NullPointerException): Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference\r\n[ERROR] TiHTTPClient: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference\r\n[ERROR] TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:195)\r\n[ERROR] TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:84)\r\n[ERROR] TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1194)\r\n[ERROR] TiHTTPClient: \tat java.lang.Thread.run(Thread.java:818)\r\n[ERROR] TiHTTPClient: (TiHttpClient-20) [1,593183] HTTP Error (java.lang.NullPointerException): Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference\r\n[ERROR] TiHTTPClient: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference\r\n[ERROR] TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:195)\r\n[ERROR] TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:84)\r\n[ERROR] TiHTTPClient: \tat ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1194)\r\n[ERROR] TiHTTPClient: \tat java.lang.Thread.run(Thread.java:818)\r\n", "updateAuthor": { "name": "jalo@emtnordic.com", "key": "jalo@emtnordic.com", "displayName": "Jacob Lorenzen", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2015-10-27T08:26:14.000+0000", "updated": "2015-10-27T08:26:14.000+0000" }, { "id": "367958", "author": { "name": "jalo@emtnordic.com", "key": "jalo@emtnordic.com", "displayName": "Jacob Lorenzen", "active": true, "timeZone": "Europe/Copenhagen" }, "body": "My SDK info:\r\nAppcelerator Command-Line Interface, version 5.0.3\r\nCopyright (c) 2014-2015, Appcelerator, Inc. All Rights Reserved.\r\n\r\n10/27/2015, 8:01:17 AM\r\n\r\nOperating System\r\n Name = Mac OS X\r\n Version = 10.10.5\r\n Architecture = 64bit\r\n # CPUs = 4\r\n Memory = 12884901888\r\n\r\nNode.js\r\n Node.js Version = 0.12.7\r\n npm Version = 2.11.3\r\n\r\nTitanium CLI\r\n CLI Version = 5.0.5\r\n\r\nTitanium SDK\r\n SDK Version = 5.0.2.GA\r\n SDK Path = /Users/jalo/Library/Application Support/Titanium/mobilesdk/osx/5.0.2.GA\r\n Target Platform = android", "updateAuthor": { "name": "jalo@emtnordic.com", "key": "jalo@emtnordic.com", "displayName": "Jacob Lorenzen", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2015-10-27T08:28:36.000+0000", "updated": "2015-10-27T08:28:36.000+0000" }, { "id": "367959", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2015-10-27T08:34:02.000+0000", "updated": "2015-10-27T08:34:24.000+0000" } ], "maxResults": 11, "total": 11, "startAt": 0 } } }