[TIMOB-2798] Android: xhr NPE for posts with empty http body
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-05-17T18:22:45.000+0000 |
Affected Version/s | Release 1.6.0 |
Fix Version/s | Release 1.7.0, Sprint 2011-20 |
Components | Android |
Labels | android, defect, reported-1.6.0, rplist |
Reporter | Anthony Webb |
Assignee | Don Thorp |
Created | 2011-04-15T03:29:48.000+0000 |
Updated | 2011-05-17T18:22:45.000+0000 |
Description
I have a page that returns a 200 response, but nothing in the
body.
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{Ti.API.info('I am in utf-8 onload for POST');};
xhr.onerror = function()
{Ti.API.info('I am in utf-8 error for POST');};
xhr.open("POST","http://mywebsite.com/script.cfm");
xhr.send({"a":"hi", "b":"there"});
If the sript I post to doesn't return a body, only a 200, then the
NPE happens. If I change the script to return any text at all the
NPE is avoided.
The resulting log of the NPE looks like:
[TRACE] E/TiUIView( 1729): (main) [5383,101697] TAP, TAP, TAP on [Ti.UI.Button]
[TRACE] D/TiHttpClient( 1729): (kroll$3) [10,101707] Setting ready state to 1
[TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 12700 objects / 611088 bytes in 124ms
[TRACE] D/dalvikvm( 1729): GC_FOR_MALLOC freed 1967 objects / 297312 bytes in 369ms
[TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [2521,104228] Setting ready state to 2
[TRACE] D/TiHttpClient( 1729): (TiHttpClient-2) [0,104228] Setting ready state to 3
[TRACE] E/TiHttpClient( 1729): (TiHttpClient-2) [2,104230] HTTP Error (java.lang.NullPointerException): java.lang.NullPointerException
[TRACE] E/TiHttpClient( 1729): java.lang.NullPointerException
[TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.finishedReceivingEntityData(TiHTTPClient.java:321)
[TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:257)
[TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$LocalResponseHandler.handleResponse(TiHTTPClient.java:166)
[TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
[TRACE] E/TiHttpClient( 1729): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:637)
[TRACE] E/TiHttpClient( 1729): at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1010)
[TRACE] E/TiHttpClient( 1729): at java.lang.Thread.run(Thread.java:1096)
[TRACE] I/TiHttpClient( 1729): (TiHttpClient-2) [3,104233] Sending error java.lang.NullPointerException
Associated Helpdesk Ticket
http://developer.appcelerator.com/helpdesk/view/65371">http://developer.appcelerator.com/helpdesk/view/65371
I have the same issue. The app seems to work fine. I hope this error doesn't cause issues when we go live.
Not sure why this was assigned to me...
Needs confirming.
Confirmed resolved on 1.7.0 RC1 on Eris 2.1