[TIMOB-3192] HTTPClient crashes with java.lang.NullPointerException for 0 length responses
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2011-04-26T09:13:25.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.7.0, Sprint 2011-11 |
Components | Android |
Labels | android, defect, reported-1.5.1 |
Reporter | Daniel Cameron |
Assignee | Don Thorp |
Created | 2011-04-15T03:39:08.000+0000 |
Updated | 2011-04-26T09:13:25.000+0000 |
Description
HTTPClient crashes when the HTTP Response sent is 0 bytes long.
Versions:
- Titanium Mobile SDK 1.5.1
- Android SDK r9
Debugging Trace:
[TRACE] D/TiHttpClient( 1727): (kroll$1) [96,2260] Setting ready state to 1 [TRACE] W/TiTabActivity( 1727): (main) [94,2354] Notifying TiTabGroup, activity is created [TRACE] D/qemud ( 38): fdhandler_accept_event: accepting on fd 10 [TRACE] D/qemud ( 38): created client 0x2c938 listening on fd 15 [TRACE] D/qemud ( 38): client_fd_receive: attempting registration for service 'sensors' [TRACE] D/qemud ( 38): client_fd_receive: -> received channel id 20 [TRACE] D/qemud ( 38): client_registration: registration succeeded for client 20 [TRACE] D/qemud ( 38): fdhandler_event: disconnect on fd 15 [TRACE] I/ActivityManager( 60): Displayed activity unittest.httpclient/ti.modules.titanium.ui.TiTabActivity: 2466 ms (total 2466 ms) [TRACE] D/dalvikvm( 1727): GC_FOR_MALLOC freed 3458 objects / 210168 bytes in 150ms [TRACE] D/TiHttpClient( 1727): (TiHttpClient-1) [4134,6488] Setting ready state to 2 [TRACE] D/TiHttpClient( 1727): (TiHttpClient-1) [2,6490] Setting ready state to 3 [TRACE] E/TiHttpClient( 1727): (TiHttpClient-1) [10,6500] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1727): java.lang.NullPointerException [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:316) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:252) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:165) [TRACE] E/TiHttpClient( 1727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657) [TRACE] E/TiHttpClient( 1727): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637) [TRACE] E/TiHttpClient( 1727): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:997) [TRACE] E/TiHttpClient( 1727): at java.lang.Thread.run(Thread.java:1096) [TRACE] I/TiHttpClient( 1727): (TiHttpClient-1) [28,6528] Sending error java.lang.NullPointerException [TRACE] W/TiConvert( 1727): (kroll$1) [28,6556] Unsupported type class ti.modules.titanium.network.HTTPClientProxy [ERROR] [3,6559] HTTPClient error={"error":"java.lang.NullPointerException"}
Repo steps:
- Create New Project
- Add the following to app.js:
var xhr = Titanium.Network.createHTTPClient();
xhr.onerror = function (e) {
Ti.API.error('HTTPClient error='+JSON.stringify(e));
};
xhr.onload = function () {
Ti.API.info('status=' + xhr.status);
Ti.API.info('responseText=' + xhr.responseText);
Ti.API.info('responseText=' + xhr.responseText);
};
xhr.open('GET', 'http://www.danielcameron.com/m/empty.html'); // can replace with any HTTP request for a 0 byte file
xhr.send();
Titanium also crashes when sending null post parameters:
xhr.send({ somearg: 'ok', thisCrashesApp: null });
Assigning to hopefully the correct person.
Created, new ticket #3358 for the issue regarding send with a null value.
In regards to the original issue, I am unable to reproduce on latest build on master. Is someone else able to confirm that this is still an issue on the latest build?
Titanium Mobile SDK 1.6.1
Android SDK r10
Retested with above versions with an APIs 2.2 emulator and no longer crashing. Looks like it got fixed somewhere between 1.5.1 and 1.6.1.