Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25518] Android App Crash due to Attempt to invoke virtual method 'void java.net.HttpURLConnection.disconnect()' on a null object reference

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-01-24T21:21:08.000+0000
Affected Version/sn/a
Fix Version/sRelease 7.0.2
ComponentsAndroid
Labelsn/a
ReporterMuhammad Ahmed Fahad
AssigneeGary Mathews
Created2017-08-17T02:46:37.000+0000
Updated2018-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

FileDateSize
Screen Shot 2017-08-28 at 10.20.10 AM.png2017-08-28T02:20:38.000+000032913
Screen Shot 2017-11-15 at 11.22.54 AM.png2017-11-15T03:37:42.000+0000132802
Screen Shot 2017-11-15 at 11.23.14 AM.png2017-11-15T03:37:42.000+0000135486

Comments

  1. Muhammad Ahmed Fahad 2017-08-28

    Any updates on this one? !Screen Shot 2017-08-28 at 10.20.10 AM.png|thumbnail!
  2. Gary Mathews 2017-09-11

    [~fahad86] Could you provide a test case that can reproduce the issue?
  3. Muhammad Ahmed Fahad 2017-09-12

    @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
  4. Muhammad Ahmed Fahad 2017-09-12

    Should hopefully be a small change. Would love to see this as a part of 6.2.0
  5. Sharif AbuDarda 2017-10-29

    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.
  6. Muhammad Ahmed Fahad 2017-10-30

    @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.
  7. Muhammad Ahmed Fahad 2017-11-15

    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)
  8. Gary Mathews 2017-11-15

    master: https://github.com/appcelerator/titanium_mobile/pull/9605
  9. Lokesh Choudhary 2018-01-11

    [~gmathews], Can you please provide a test code which I can work with.
  10. Muhammad Ahmed Fahad 2018-01-18

    @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
  11. Gary Mathews 2018-01-18

    7_0_X: https://github.com/appcelerator/titanium_mobile/pull/9708
  12. Lokesh Choudhary 2018-01-19

    FR Passed. Master PR merged. Waiting for merge to get enabled for backport.
  13. Lokesh Choudhary 2018-01-24

    Backport PR merged.
  14. Lokesh Choudhary 2018-01-25

    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

JSON Source