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

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

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.