Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19555] Android: HTTPClient fails when no contentType is specified in response

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-09-21T07:53:59.000+0000
Affected Version/sRelease 5.0.0
Fix Version/sRelease 5.1.0
ComponentsAndroid
Labelsn/a
ReporterManojkumar Murugesan
AssigneeAshraf Abu
Created2015-09-19T18:25:49.000+0000
Updated2015-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

Comments

  1. Manojkumar Murugesan 2015-09-20

    Opened a pull request here - https://github.com/appcelerator/titanium_mobile/pull/7210
  2. Hans Knöchel 2015-09-21

    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?
  3. Manojkumar Murugesan 2015-09-21

    [~hansknoechel]: I'm unable to share the URL here, but have shared it already with the support case associated with this ticket.
  4. Ashraf Abu 2015-09-21

    PR merged: https://github.com/appcelerator/titanium_mobile/pull/7210 Thank you [~mano_mykingdom]
  5. Muhammad Ahmed Fahad 2015-09-25

    shouldn't this be merged into 5.0.1?
  6. Ashraf Abu 2015-10-02

  7. Lokesh Choudhary 2015-10-27

    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

JSON Source