Skip to content

PushBroadcastReceiver: java.lang.NullPointerException #260

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
MojRoid opened this issue Nov 20, 2015 · 7 comments
Closed

PushBroadcastReceiver: java.lang.NullPointerException #260

MojRoid opened this issue Nov 20, 2015 · 7 comments

Comments

@MojRoid
Copy link

MojRoid commented Nov 20, 2015

Push is working for mostly without issues, however just got this crash from one of my users, any ideas?

Fatal Exception: java.lang.RuntimeException: Unable to start receiver dev.moj.pad.util.PushBroadcastReceiver: java.lang.NullPointerException
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:2237)
       at android.app.ActivityThread.access$1500(ActivityThread.java:131)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4754)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       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.onPushOpen(ParsePushBroadcastReceiver.java:198)
       at com.parse.ParsePushBroadcastReceiver.onReceive(ParsePushBroadcastReceiver.java:123)
       at android.app.ActivityThread.handleReceiver(ActivityThread.java:2230)
       at android.app.ActivityThread.access$1500(ActivityThread.java:131)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1272)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:4754)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:511)
       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)
@parse-github-bot
Copy link

Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.

Please try the latest SDK. Our release notes have details about what issues were fixed in each release.

In addition, you might find the following resources helpful:

@wangmengyan95
Copy link
Contributor

Hi @AraBisTiC, I check our source code, this problem happens becuase we can not get the raw push data from the intent. When we try to use null to build a JSON object, the exception is thrown.

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

I wonder

  1. Do you push service besides Parse?
  2. Can you repo this problem? Is it possible for you to get the all the extras in the intent?
    Thanks.

@MojRoid
Copy link
Author

MojRoid commented Nov 20, 2015

That's all the information I have unfortunately as I'm using Crashlytics to obtain crash dumps. I've sent a couple dozen pushes without problems however. If there's not much to go by, I'll keep an eye on it and update should it happen again. ^^

@alexblack
Copy link

This happens in the wild for me too, here is the work around I use:

@Override
  public void onReceive(final Context context, final Intent intent) {
    Log.d(TAG, "onReceive: " + intent);

    try {
      super.onReceive(context, intent);
    } catch (NullPointerException e) {
      reportNPE(context, intent, e);
    }

@MojRoid
Copy link
Author

MojRoid commented Nov 24, 2015

sweet fix. Thanks @alexblack

@alexblack
Copy link

Glad I could help!

I reported what looks like the same bug last year: https://developers.facebook.com/bugs/1503917729875663/

@wangmengyan95
Copy link
Contributor

Thanks @alexblack. @AraBisTiC, I have already added the null checking for the raw data from GCM. It should not bother you anymore. If you want to add log for the NPE case, @alexblack' way is a good solution.

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

5 participants