[TIMOB-19555] Android: HTTPClient fails when no contentType is specified in response
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-09-21T07:53:59.000+0000 |
Affected Version/s | Release 5.0.0 |
Fix Version/s | Release 5.1.0 |
Components | Android |
Labels | n/a |
Reporter | Manojkumar Murugesan |
Assignee | Ashraf Abu |
Created | 2015-09-19T18:25:49.000+0000 |
Updated | 2015-10-27T00:27:49.000+0000 |
Description
HTTPClient fails with the error below,
[ERROR] : TiHTTPClient: (TiHttpClient-40) [9,1211] 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
[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
[ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:196)
[ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:84)
[ERROR] : TiHTTPClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1195)
[ERROR] : TiHTTPClient: at java.lang.Thread.run(Thread.java:818)
when no contentType is specified in response header. Till 4.x this was working, breaking only on 5.0.0.GA.
*+Note:+* As mentioned in docs here http://developer.android.com/reference/java/net/URLConnection.html#getContentType() it may return a string or null when type is unknown which is not handled here https://github.com/appcelerator/titanium_mobile/blob/24c69f037e9b4f91713c33c7afb7ffd31bc77933/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java#L193
Opened a pull request here - https://github.com/appcelerator/titanium_mobile/pull/7210
Thank you [~mano_mykingdom]. To reproduce the issue in our QA team, we need an URL which matches your environment (not having a contentType). Can you provide that URL?
[~hansknoechel]: I'm unable to share the URL here, but have shared it already with the support case associated with this ticket.
PR merged: https://github.com/appcelerator/titanium_mobile/pull/7210 Thank you [~mano_mykingdom]
shouldn't this be merged into 5.0.1?
Verified the fix. HTTPClient returns success with this fix. Closing. Environment: Appc Studio : 4.4.0.201510231805 Ti SDK : 5.1.0.v20151022152020 Ti CLI : 5.0.5 Alloy : 1.7.18 MAC Yosemite : 10.10.5 Appc NPM : 4.2.1-6 Appc CLI : 5.1.0-38 Node: v0.10.37 Nexus 5 - Android 6.0