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) {
73
73
* Even if we are cancelled for any reason, it should still service all items in the queue if it can.
74
74
*
75
75
*/
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
+
77
92
final String componentClass = work .getIntent ().getComponent ().getClassName ();
78
93
Class <?> clazz = null ;
79
94
logger .info ("Processing work: " + work + ", component: " + componentClass );
@@ -175,6 +190,13 @@ public void onCreate() {
175
190
176
191
@ Override
177
192
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
+ }
178
200
}
179
201
180
202
@ Override
You can’t perform that action at this time.
0 commit comments