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 @@ -73,7 +73,22 @@ protected Void doInBackground(Void... params) {
7373 * Even if we are cancelled for any reason, it should still service all items in the queue if it can.
7474 *
7575 */
76- while (!(cancelled = isCancelled ()) && (work =mParams .dequeueWork ()) != null ) {
76+ while (!(cancelled = isCancelled ())) {
77+ try {
78+ // This is pertaining to this issue:
79+ // https://issuetracker.google.com/issues/63622293
80+ // The service was probabably destroyed but we didn't cancel the
81+ // processor. It causes an exception in dequeueWork.
82+ // We are also now calling cancel in onDestroy
83+ if ((work = mParams .dequeueWork ()) == null ) {
84+ return null ;
85+ }
86+ }
87+ catch (Exception e ) {
88+ logger .error ("Exception in JobWorkService:doInBackground mParams.dequeueWork() " , e );
89+ return null ;
90+ }
91+
7792 final String componentClass = work .getIntent ().getComponent ().getClassName ();
7893 Class <?> clazz = null ;
7994 logger .info ("Processing work: " + work + ", component: " + componentClass );
@@ -175,6 +190,13 @@ public void onCreate() {
175190
176191 @ Override
177192 public void onDestroy () {
193+ // This is pertaining to this issue:
194+ // https://issuetracker.google.com/issues/63622293
195+ // The service was probabably destroyed but we didn't cancel the
196+ // processor.
197+ if (mCurProcessor != null ) {
198+ mCurProcessor .cancel (true );
199+ }
178200 }
179201
180202 @ Override
You can’t perform that action at this time.
0 commit comments