BlackBerry Device Software version 7.0 throws a NullPointerException when receiving an data push

by Retired on ‎10-13-2011 03:57 PM - edited on ‎01-26-2012 11:24 AM by BlackBerry Development Advisor (3,916 Views)

Symptoms

 

In BlackBerry® 7, an issue has been identified where, when receiving a data push, a NullPointerException may be thrown upon calling StreamConnection#close(). Depending on how the application is coded this may result in the data being lost.

Diagnosis

 

Affects:

  • BlackBerry smartphones running BlackBerry 7
  • BlackBerry Java® Applications

If an Java-based application utilizes data push has been tested to work fine in BlackBerry® Device Software versions prior to BlackBerry 7 but fails to receive data properly in BlackBerry 7 then this is likely the cause. Debugging this application would be the easiest way to confirm if a NullPointerException is thrown.

 

Note: This issue does not appear to affect BlackBerry® WebWorks™ applications that receive data pushes

 

You can track the status of this issue in Issue Tracker here: https://www.blackberry.com/jira/browse/JAVAAPI-2062

Solution

 

Until a fix is implemented into device code the workaround is to make use of the MDSPushInputStream as it is demonstrated in the HTTPPushDemo sample application. By calling MDSPushInputStream#accept() in the same manner shown in this sample, the following call to StreamConnection#close() should succeed.

 

The call to MDSPushInputStream#accept() will not alter the functionality of the application, this call simply responds back to the BlackBerry® Enterprise Server to acknowledge that the push was received. It is used for pushes that require application-level reliability. The added network traffic is minimal.