Skip to content

Potential NPE when handling data #336

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
INRIX-Owais-Ali opened this issue Jan 7, 2016 · 2 comments
Closed

Potential NPE when handling data #336

INRIX-Owais-Ali opened this issue Jan 7, 2016 · 2 comments

Comments

@INRIX-Owais-Ali
Copy link

We're seeing the following crash being reported in our app (using Parse 1.11.0):

Fatal Exception: java.lang.RuntimeException: Unable to start receiver com.inrix.android.app.push.PdaBroadcastReceiver: java.lang.NullPointerException
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:2325)
       at android.app.ActivityThread.access$1500(ActivityThread.java:130)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1287)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4847)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:535)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by java.lang.NullPointerException
       at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
       at org.json.JSONTokener.nextValue(JSONTokener.java:94)
       at org.json.JSONObject.(JSONObject.java)
       at org.json.JSONObject.(JSONObject.java)
       at com.parse.ParsePushBroadcastReceiver.onPushReceive(SourceFile:141)
       at com.parse.ParsePushBroadcastReceiver.onReceive(SourceFile:117)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:2312)
       at android.app.ActivityThread.access$1500(ActivityThread.java:130)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1287)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4847)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:535)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
       at dalvik.system.NativeStart.main(NativeStart.java)

The relevant code block is:

    JSONObject pushData = null;
    try {
      pushData = new JSONObject(intent.getStringExtra(KEY_PUSH_DATA));
    } catch (JSONException e) {
      PLog.e(TAG, "Unexpected JSONException when receiving push data: ", e);
    }

It seems like JSONObject constructor can throw NPE if the value being passed in is null (or there may be some other root cause).

@grantland
Copy link
Contributor

Fixed in 1.12.0 with #261

@INRIX-Owais-Ali
Copy link
Author

We'll update to 1.12 - I should've checked the master branch to see if this was fixed already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants