Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2798] Android: xhr NPE for posts with empty http body

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionFixed
Resolution Date2011-05-17T18:22:45.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sRelease 1.7.0, Sprint 2011-20
ComponentsAndroid
Labelsandroid, defect, reported-1.6.0, rplist
ReporterAnthony Webb
AssigneeDon Thorp
Created2011-04-15T03:29:48.000+0000
Updated2011-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

Comments

  1. Dawson Toth 2011-04-15

    Associated Helpdesk Ticket

    http://developer.appcelerator.com/helpdesk/view/65371">http://developer.appcelerator.com/helpdesk/view/65371

  2. David Silva Smith 2011-04-15

    I have the same issue. The app seems to work fine. I hope this error doesn't cause issues when we go live.

  3. Dawson Toth 2011-05-17

    Not sure why this was assigned to me...
  4. Dawson Toth 2011-05-17

  5. Don Thorp 2011-05-17

    Needs confirming.
  6. Don Thorp 2011-05-17

    Confirmed resolved on 1.7.0 RC1 on Eris 2.1

JSON Source