0
votes

We are using worklight 6.2 to build a Android native client. And recently we have encountered an exception would leads to app crash when receiving push notification. We have followed the official tutorial to build this client.

Scenario

  1. The app was killed
  2. send a push from WL server
  3. At client side. we can observer a notification
  4. After clicking the notification to start up the App. it crashed with the following error logs.

The logs are as following.

12-12 10:43:41.995: E/AndroidRuntime(31144): java.lang.RuntimeException: Error receiving broadcast Intent { act=com.MeaWallet.MeaWallet.C2DM_REGISTERED flg=0x10 (has extras) } in com.worklight.wlclient.api.WLPush$3@2e2deef4
12-12 10:43:41.995: E/AndroidRuntime(31144):    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:871)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at android.os.Handler.handleCallback(Handler.java:739)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at android.os.Handler.dispatchMessage(Handler.java:95)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at android.os.Looper.loop(Looper.java:135)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at android.app.ActivityThread.main(ActivityThread.java:5221)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at java.lang.reflect.Method.invoke(Native Method)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at java.lang.reflect.Method.invoke(Method.java:372)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
12-12 10:43:41.995: E/AndroidRuntime(31144): Caused by: java.util.ConcurrentModificationException
12-12 10:43:41.995: E/AndroidRuntime(31144):    at java.util.ArrayList$ArrayListIterator.remove(ArrayList.java:586)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at com.worklight.wlclient.api.WLPush.dispatchPendings(WLPush.java:712)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at com.worklight.wlclient.api.WLPush.updateTokenCallback(WLPush.java:744)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at com.worklight.wlclient.api.WLPush.access$400(WLPush.java:113)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at com.worklight.wlclient.api.WLPush$3.onReceive(WLPush.java:538)
12-12 10:43:41.995: E/AndroidRuntime(31144):    at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:861)
12-12 10:43:41.995: E/AndroidRuntime(31144):    ... 8 more
1

1 Answers

0
votes

This is due to a synchronization issue. There's a resource named "pendingPushEvents" in WLPush.java. And two of method could UPDATE this.

  1. dispatchPendings();
  2. onMessage();

In my application, These two methods were invoked by two threads at the same time. So the resource was updated by two threads simultaneously, which leads to this situation.