[TIMOB-25518] Android App Crash due to Attempt to invoke virtual method 'void java.net.HttpURLConnection.disconnect()' on a null object reference
GitHub Issue | n/a |
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-01-24T21:21:08.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.0.2 |
Components | Android |
Labels | n/a |
Reporter | Muhammad Ahmed Fahad |
Assignee | Gary Mathews |
Created | 2017-08-17T02:46:37.000+0000 |
Updated | 2018-01-25T00:03:07.000+0000 |
Description
Recently tracking a lot of the following errors. Null checks need to be placed in TiHTTPClient.java.
e.g.
1)
java.lang.NullPointerException
0 java.lang.NullPointerException: Attempt to invoke virtual method 'void java.net.HttpURLConnection.disconnect()' on a null object reference
! 1 at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1293)
2 at java.lang.Thread.run(Thread.java:818)
2)
java.lang.NullPointerException: Attempt to invoke a virtual method on a null object reference
! 1 at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1293)
2 at java.lang.Thread.run(Thread.java:762)
Attachments
Any updates on this one? !Screen Shot 2017-08-28 at 10.20.10 AM.png|thumbnail!
[~fahad86] Could you provide a test case that can reproduce the issue?
@Gary Mathews, sorry.. I'm not able to reproduce these errors as these were collected as a part of production crash dumps. What I would love to see is coding around the areas where these errors are thrown handling the errors gracefully (null checks) preventing the application from crashes. Do let me know if you need any more info. Thanks and Regards
Should hopefully be a small change. Would love to see this as a part of 6.2.0
Hello, it would be helpful to move forward with the ticket if you provide a sample reproducible code. Thanks. Also add trace log of the issue. Thanks.
@Sharif AbuDarda we use TiHTTPClient quite extensively but we don't have much visibility as to where exactly the crashes/exceptions occur. But one thing that we know is that these crashes occur quite frequently. This is amongst the only 2 main crashes that we see often in our app.
The issue seems to be happening after a period of inactivity of the app. We use a publisher subscriber service which I guess maintains connections for extended periods. The crashes seem to be occurring after periods of inactivity. !Screen Shot 2017-11-15 at 11.22.54 AM.png|thumbnail! !Screen Shot 2017-11-15 at 11.23.14 AM.png|thumbnail! As for the details about the crashdumps we only have this: Crashed Thread 0 java.lang.NullPointerException: Attempt to invoke virtual method 'void java.net.HttpURLConnection.disconnect()' on a null object reference ! 1 at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1293) 2 at java.lang.Thread.run(Thread.java:818)
master: https://github.com/appcelerator/titanium_mobile/pull/9605
[~gmathews], Can you please provide a test code which I can work with.
@Lokesh Choudhary can this be approved without code to reproduce the problem? I guess the workaround code for this was implemented purely based on the crash dumps. @Gary Mathews if you did however come-up with your own test case please list. Thanks and Regards
7_0_X: https://github.com/appcelerator/titanium_mobile/pull/9708
FR Passed. Master PR merged. Waiting for merge to get enabled for backport.
Backport PR merged.
Verified the fix with SDK 7.1.0.v20180124153334 & 7.0.2.v20180124142857. Closing. Studio Ver: 5.0.0.201712081732 SDK Ver: 7.1.0.v20180124153334 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.11 Appc CLI: 7.0.1 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.10 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ samsung SM-G955U1 --- Android 7.0 ⇨ google Nexus 5 --- Android 6.0.1