Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26010] Android: TiHTTPClient getResponseHeader throws a NullPointerException

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-05-03T14:19:15.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.3.0
ComponentsAndroid
Labelsandroid, exception, httpclient
ReporterAndrea Vitale
AssigneeHans Knöchel
Created2018-05-01T17:57:26.000+0000
Updated2018-06-20T16:55:07.000+0000

Description

Calling
http.getResponseHeader()
throws an exception:
[WARN]  W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.Map.isEmpty()' on a null object reference
[WARN]  W/System.err: 	at ti.modules.titanium.network.TiHTTPClient.getResponseHeader(TiHTTPClient.java:716)
[WARN]  W/System.err: 	at ti.modules.titanium.network.HTTPClientProxy.getResponseHeader(HTTPClientProxy.java:135)
[WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method)
[WARN]  W/System.err: 	at org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:75)
[WARN]  W/System.err: 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1200)
[WARN]  W/System.err: 	at android.os.Handler.dispatchMessage(Handler.java:98)
[WARN]  W/System.err: 	at android.os.Looper.loop(Looper.java:154)
[WARN]  W/System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6186)
[WARN]  W/System.err: 	at java.lang.reflect.Method.invoke(Native Method)
[WARN]  W/System.err: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
[WARN]  W/System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
I was trying to send some data to sentry.io, maybe inside the response there were no headers.

Comments

  1. Hans Knöchel 2018-05-02

    This looks valid! Lets add a null check for this scenario.
  2. Mostafizur Rahman 2018-05-03

    Hello [~Andrea.Vitale], Thanks for sharing with us. Please create a full reproducible test code and provide here for us to test the issue. Did you get same error in all android devices? Thanks.
  3. Andrea Vitale 2018-05-03

    Hi, a check is really simple: make a request to a server that doesn't append any response header (like sentry.io) and the exception is thrown. I created a PR to simply add a null check: https://github.com/appcelerator/titanium_mobile/pull/10025
  4. Lokesh Choudhary 2018-06-20

    Verified the fix is present in SDK 7.3.0.v20180618182516. Closing.

JSON Source