[TIMOB-26010] Android: TiHTTPClient getResponseHeader throws a NullPointerException
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-05-03T14:19:15.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.3.0 |
Components | Android |
Labels | android, exception, httpclient |
Reporter | Andrea Vitale |
Assignee | Hans Knöchel |
Created | 2018-05-01T17:57:26.000+0000 |
Updated | 2018-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.
This looks valid! Lets add a null check for this scenario.
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.
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
Verified the fix is present in SDK 7.3.0.v20180618182516. Closing.