{ "id": "155708", "key": "TIMOB-20583", "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": "17706", "name": "Release 5.4.0", "archived": false, "released": true, "releaseDate": "2016-08-11" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-03-23T08:33:33.000+0000", "created": "2016-03-14T08:04:16.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "android", "httpclient", "timeout" ], "versions": [], "issuelinks": [], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-07-14T23:04:17.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": "Being on 2G my http request will timeout and bringing up the following error message:\r\n\r\n\r\n{code:java}\r\n (TiHttpClient-3) [96625,96625] HTTP Error (java.net.SocketTimeoutException): java.net.SocketTimeoutException\r\n java.net.SocketTimeoutException\r\n \tat java.net.PlainSocketImpl.read(PlainSocketImpl.java:484)\r\n \tat java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:37)\r\n \tat java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)\r\n \tat com.android.okhttp.okio.Okio$2.read(Okio.java:135)\r\n \tat com.android.okhttp.okio.AsyncTimeout$2.read(AsyncTimeout.java:211)\r\n \tat com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)\r\n \tat com.android.okhttp.okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)\r\n \tat com.android.okhttp.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)\r\n \tat com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191)\r\n \tat com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)\r\n \tat com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:904)\r\n \tat com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:788)\r\n \tat com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:463)\r\n \tat com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:408)\r\n \tat com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaders(HttpURLConnectionImpl.java:170)\r\n \tat com.android.okhttp.internal.huc.HttpURLConnectionImpl.getHeaderField(HttpURLConnectionImpl.java:212)\r\n \tat java.net.URLConnection.getHeaderFieldInt(URLConnection.java:543)\r\n \tat java.net.URLConnection.getContentLength(URLConnection.java:315)\r\n \tat ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:159)\r\n \tat ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:85)\r\n \tat ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1207)\r\n \tat java.lang.Thread.run(Thread.java:818)\r\n java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.Map.isEmpty()' on a null object reference\r\n \tat ti.modules.titanium.network.TiHTTPClient.getAllResponseHeaders(TiHTTPClient.java:615)\r\n \tat ti.modules.titanium.network.HTTPClientProxy.getAllResponseHeaders(HTTPClientProxy.java:99)\r\n \tat org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method)\r\n \tat org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:73)\r\n \tat org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1155)\r\n \tat android.os.Handler.dispatchMessage(Handler.java:98)\r\n \tat android.os.Looper.loop(Looper.java:168)\r\n \tat org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)\r\n E/TiExceptionHandler(7403): (main) [59,96684] ----- Titanium Javascript Runtime Error -----\r\n E/TiExceptionHandler(7403): (main) [0,96684] - In ti:/console.js:25,62\r\n E/TiExceptionHandler(7403): (main) [0,96684] - Message: Uncaught Error: Attempt to invoke interface method 'boolean java.util.Map.isEmpty()' on a null object reference\r\n E/TiExceptionHandler(7403): (main) [1,96685] - Source: \t\t\t\t( arg.hasOwnProperty('toString') ? arg.toString() : JSON.stringify(arg) ) \r\n{code}\r\n\r\nThe problem is here:\r\nhttps://github.com/appcelerator/titanium_mobile/blob/dcd73f54156cdd0a9f40ae9a2339ccb68e8c216e/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L615\r\nresponseHeaders is null so isEmpty() can't be called\r\n\r\nTest code:\r\n{code:java}\r\nvar url = \"http://my.server.com\";\r\nvar client = Ti.Network.createHTTPClient({\r\n onload : function(e) {\r\n Ti.API.info(\"Received text: \" + this.responseText);\r\n alert('success');\r\n },\r\n onerror : function(e) {\r\n Ti.API.debug(e.error);\r\n alert('error');\r\n },\r\n timeout : 5000\r\n});\r\n\r\nclient.open(\"GET\", url);\r\nclient.send();\r\n{code}\r\nI've changed to 2G and went into a room with bad reception to force the timeout", "attachment": [], "flagged": false, "summary": "Android: TiHTTPClient.getAllResponseHeaders() throws NullPointerException on timeout", "creator": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "environment": "Android 6.0.1 (HTC A9)\r\nTi SDK 5.2.0", "closedSprints": [ { "id": 597, "state": "closed", "name": "2016 Sprint 06 SDK", "startDate": "2016-03-12T01:30:59.982Z", "endDate": "2016-03-26T00:30:00.000Z", "completeDate": "2016-03-28T03:38:09.726Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "379900", "author": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "body": "5.4.0: https://github.com/appcelerator/titanium_mobile/pull/7855\r\n5.3.x: https://github.com/appcelerator/titanium_mobile/pull/7857\r\n5.2.x: https://github.com/appcelerator/titanium_mobile/pull/7856\r\n\r\n\"Titanium Javascript Runtime Error\" alert won't appear. It will just go into the error branch after timeout\r\n\r\nTested on HTC A9, Android 6", "updateAuthor": { "name": "michael", "key": "michael", "displayName": "Michael Gangolf", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-03-16T18:29:48.000+0000", "updated": "2016-03-16T18:29:48.000+0000" }, { "id": "380485", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "PR Master 5.4.0: https://github.com/appcelerator/titanium_mobile/pull/7855 (merged)\r\n5.3.x: https://github.com/appcelerator/titanium_mobile/pull/7857 (PR Closed, Not Merged)\r\n5.2.x: https://github.com/appcelerator/titanium_mobile/pull/7856 (PR Closed, Not Merged)", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-03-23T08:32:51.000+0000", "updated": "2016-03-23T08:34:08.000+0000" }, { "id": "390748", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\nNo null pointer exception thrown.\r\n\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.7.0.201607111053\r\nTi SDK : 5.4.0.v20160713141635\r\nTi CLI : 5.0.9\r\nAlloy : 1.9.1\r\nMAC El Capitan : 10.11.5\r\nAppc NPM : 4.2.8-1\r\nAppc CLI : 5.4.0-33\r\nNode: 4.4.4\r\nNexus 6 - Android 6.0.1", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-07-14T23:04:00.000+0000", "updated": "2016-07-14T23:04:00.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }