java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference

Appcelerator JIRA | Manojkumar Murugesan | 1 year ago
  1. 0

    HTTPClient fails with the error below, {code} [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) {code} 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

    Appcelerator JIRA | 1 year ago | Manoj Kumar M
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
  2. 0

    HTTPClient fails with the error below, {code} [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) {code} 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

    Appcelerator JIRA | 1 year ago | Manojkumar Murugesan
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
  3. 0

    h2. Steps to reproduce h3. Create xhr that pings an endpoint that returns 'true' or 'false {code} function doit() { var xhr = Ti.Network.createHTTPClient({ onload: function onLoad(e) { alert("Received: Status = " + e.status + ", Value = " + e.responseText); }, onerror: function onError(e) { alert("Error: Status = " + e.status + ", Value = " + e.responseText); } }); xhr.open("GET", "https://13b6379a34068a7bb6c483d30f362f550675a41c.cloudapp-enterprise.appcelerator.com/t"); xhr.send(); } {code} h2. Error generated {code} [ERROR] TiHTTPClient: (TiHttpClient-1) [3054,3054] 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:195) [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:1194) [ERROR] TiHTTPClient: at java.lang.Thread.run(Thread.java:818) {code} h2. Endpoint {code} function t(req, res){ res.end((((new Date()).getTime() & 1) == 1).toString()); } {code}

    Appcelerator JIRA | 1 year ago | Seth Toda
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    h2. Steps to reproduce h3. Create xhr that pings an endpoint that returns 'true' or 'false {code} function doit() { var xhr = Ti.Network.createHTTPClient({ onload: function onLoad(e) { alert("Received: Status = " + e.status + ", Value = " + e.responseText); }, onerror: function onError(e) { alert("Error: Status = " + e.status + ", Value = " + e.responseText); } }); xhr.open("GET", "https://13b6379a34068a7bb6c483d30f362f550675a41c.cloudapp-enterprise.appcelerator.com/t"); xhr.send(); } {code} h2. Error generated {code} [ERROR] TiHTTPClient: (TiHttpClient-1) [3054,3054] 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:195) [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:1194) [ERROR] TiHTTPClient: at java.lang.Thread.run(Thread.java:818) {code} h2. Endpoint {code} function t(req, res){ res.end((((new Date()).getTime() & 1) == 1).toString()); } {code}

    Appcelerator JIRA | 1 year ago | Seth Toda
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference
  6. 0

    If I try to cancel a just created HttpClient request (eg on a input onchange search), I got the below errors. With SDK 3.4.1 I got this error: {noformat} [ERROR] : TiHttpClient: (TiHttpClient-3) [0,4790] HTTP Error (java.lang.IllegalStateException): Connection pool shut down. [ERROR] : TiHttpClient: java.lang.IllegalStateException: Connection pool shut down. [ERROR] : TiHttpClient: at org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:289) [ERROR] : TiHttpClient: at org.apache.http.impl.conn.tsccm.ConnPoolByRoute$1.getPoolEntry(ConnPoolByRoute.java:243) [ERROR] : TiHttpClient: at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager$1.getConnection(ThreadSafeClientConnManager.java:181) [ERROR] : TiHttpClient: at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:331) [ERROR] : TiHttpClient: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:560) [ERROR] : TiHttpClient: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:658) [ERROR] : TiHttpClient: at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:642) [ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1341) [ERROR] : TiHttpClient: at java.lang.Thread.run(Thread.java:818) {noformat} With SDK 5.0.0 instead: {noformat} [ERROR] : TiHttpClient: (TiHttpClient-7) [0,9478] HTTP Error (java.lang.NullPointerException): Attempt to invoke interface method 'int org.apache.http.StatusLine.getStatusCode()' on a null object reference [ERROR] : TiHttpClient: java.lang.NullPointerException: Attempt to invoke interface method 'int org.apache.http.StatusLine.getStatusCode()' on a null object reference [ERROR] : TiHttpClient: at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1354) [ERROR] : TiHttpClient: at java.lang.Thread.run(Thread.java:818) {noformat} I'm pretty sure this don't happen with 3.1 or 3.2 but I can't test it at the moment. Test apps here: https://www.dropbox.com/sh/g7a7n9emtu36fzc/AADrFBNZ8UthezDd0vmKGjM1a?dl=0 Test code: {code:java} var win = Titanium.UI.createWindow({layout:'vertical', height:Titanium.UI.FILL, backgroundColor:"#FFF"}); var button = Titanium.UI.createButton({top:50,title:"create new request and cancel it after 50ms (will often throw error on logcat)"}); button.addEventListener('click', function(){ var n = Ti.Network.createHTTPClient(); n.open("GET", "http://www.google.com"); n.send(); setInterval(function(){ n.abort(); },50); }); win.add(button); win.open(); {code}

    Appcelerator JIRA | 1 year ago | carlo
    java.lang.NullPointerException: Attempt to invoke interface method 'int org.apache.http.StatusLine.getStatusCode()' on a null object reference

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      Attempt to invoke virtual method 'java.lang.String[] java.lang.String.split(java.lang.String)' on a null object reference

      at ti.modules.titanium.network.TiHTTPClient.handleResponse()
    2. ti.modules.titanium
      TiHTTPClient$ClientRunnable.run
      1. ti.modules.titanium.network.TiHTTPClient.handleResponse(TiHTTPClient.java:196)
      2. ti.modules.titanium.network.TiHTTPClient.access$1200(TiHTTPClient.java:84)
      3. ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1195)
      3 frames
    3. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:818)
      1 frame