Skip to content

Commit

Permalink
Catch completeWork exceptions when stat is invalid
Browse files Browse the repository at this point in the history
* Fixes issue #644
  • Loading branch information
jkasten2 committed Apr 2, 2019
1 parent 2a7729a commit 0ddb4e6
Showing 1 changed file with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,21 @@ public Intent getIntent() {
public void complete() {
synchronized (mLock) {
if (mParams != null) {
mParams.completeWork(mJobWork);
try {
mParams.completeWork(mJobWork);
// The following catches are to prevent errors completely work that
// is done or hasn't started.
// Example:
// Caused by java.lang.IllegalArgumentException:
// Given work is not active: JobWorkItem {
// id=4 intent=Intent { (has extras) } dcount=1
// }
// Issue: https://github.com/OneSignal/OneSignal-Android-SDK/issues/644
} catch (SecurityException e) {
Log.e(TAG, "SecurityException: Failed to run mParams.completeWork(mJobWork)!", e);
} catch(IllegalArgumentException e) {
Log.e(TAG, "IllegalArgumentException: Failed to run mParams.completeWork(mJobWork)!", e);
}
}
}
}
Expand Down

0 comments on commit 0ddb4e6

Please sign in to comment.