Implemented TODO in CoreService
The todo:
// TODO: remove this. we never set threadPool to null
The fix:
Removed most code that would be executed if threadPool were null
Reordered a little logic to make code easier to read
@@ -324,16 +324,6 @@ public abstract class CoreService extends Service {
}
};
- // TODO: remove this. we never set mThreadPool to null
- if (mThreadPool == null) {
- Timber.e("CoreService.execute (%s) called with no thread pool available; " +
- "running Runnable %d in calling thread", className, runner.hashCode());
-
- synchronized (this) {
- myRunner.run();
- serviceShutdownScheduled = startId != null;
- }
- } else {
Timber.d("CoreService (%s) queueing Runnable %d with startId %d", className, runner.hashCode(), startId);
try {
@@ -342,12 +332,11 @@ public abstract class CoreService extends Service {
} catch (RejectedExecutionException e) {
// Ignore RejectedExecutionException after we shut down the thread pool in
// onDestroy(). Still, this should not happen!
- if (!mShutdown) {
- throw e;
- }
-
+ if (mShutdown) {
Timber.i("CoreService: %s is shutting down, ignoring rejected execution exception: %s",
className, e.getMessage());
+ } else {
+ throw e;
}
}
