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) {
70
70
* Even if we are cancelled for any reason, it should still service all items in the queue if it can.
71
71
*
72
72
*/
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
+
74
89
final String componentClass = work .getIntent ().getComponent ().getClassName ();
75
90
Class <?> clazz = null ;
76
91
logger .info ("Processing work: " + work + ", component: " + componentClass );
@@ -129,6 +144,13 @@ public void onCreate() {
129
144
130
145
@ Override
131
146
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
+ }
132
154
}
133
155
134
156
@ Override
You can’t perform that action at this time.
0 commit comments