File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
shared/src/main/java/com/optimizely/ab/android/shared Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,22 @@ protected Void doInBackground(Void... params) {
7070 * Even if we are cancelled for any reason, it should still service all items in the queue if it can.
7171 *
7272 */
73- while (!(cancelled = isCancelled ()) && (work =mParams .dequeueWork ()) != null ) {
73+ while (!(cancelled = isCancelled ())) {
74+ try {
75+ // This is pertaining to this issue:
76+ // https://issuetracker.google.com/issues/63622293
77+ // The service was probabably destroyed but we didn't cancel the
78+ // processor. It causes an exception in dequeueWork.
79+ // We are also now calling cancel in onDestroy
80+ if ((work = mParams .dequeueWork ()) == null ) {
81+ return null ;
82+ }
83+ }
84+ catch (Exception e ) {
85+ logger .error ("Exception in JobWorkService:doInBackground mParams.dequeueWork() " , e );
86+ return null ;
87+ }
88+
7489 final String componentClass = work .getIntent ().getComponent ().getClassName ();
7590 Class <?> clazz = null ;
7691 logger .info ("Processing work: " + work + ", component: " + componentClass );
@@ -129,6 +144,13 @@ public void onCreate() {
129144
130145 @ Override
131146 public void onDestroy () {
147+ // This is pertaining to this issue:
148+ // https://issuetracker.google.com/issues/63622293
149+ // The service was probabably destroyed but we didn't cancel the
150+ // processor.
151+ if (mCurProcessor != null ) {
152+ mCurProcessor .cancel (true );
153+ }
132154 }
133155
134156 @ Override
You can’t perform that action at this time.
0 commit comments