ignore Errors and Exceptions in background services
Throwable includes Errors and Exceptions. Fixes stacktraces like these: java.lang.RuntimeException: An error occurred while executing doInBackground() at android.os.AsyncTask$3.done(AsyncTask.java:325) at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354) at java.util.concurrent.FutureTask.setException(FutureTask.java:223) at java.util.concurrent.FutureTask.run(FutureTask.java:242) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar) at org.apache.commons.io.FileUtils.isSymlink(FileUtils.java:3107) at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1616) at org.fdroid.fdroid.DeleteCacheService.onHandleWork(DeleteCacheService.java:32) at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:391) at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382) at android.os.AsyncTask$2.call(AsyncTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:237) ... 3 more java.lang.NoSuchMethodError: No virtual method toPath()Ljava/nio/file/Path; in class Ljava/io/File; or its super classes (declaration of 'java.io.File' appears in /system/framework/core-oj.jar) at org.apache.commons.io.FileUtils.isSymlink(FileUtils.java:3107) at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1616) at org.fdroid.fdroid.DeleteCacheService.onHandleWork(DeleteCacheService.java:32) at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:391) at android.support.v4.app.JobIntentService$CommandProcessor.doInBackground(JobIntentService.java:382) at android.os.AsyncTask$2.call(AsyncTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)
This commit is contained in:
parent
5cce64e153
commit
af1040443e
@ -28,13 +28,11 @@ public class DeleteCacheService extends JobIntentService {
|
||||
Log.w(TAG, "Deleting all cached contents!");
|
||||
try {
|
||||
File cacheDir = getCacheDir();
|
||||
if (cacheDir != null) {
|
||||
FileUtils.deleteDirectory(cacheDir);
|
||||
}
|
||||
for (File dir : ContextCompat.getExternalCacheDirs(this)) {
|
||||
FileUtils.deleteDirectory(dir);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) { // NOPMD
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class UpdateService extends JobIntentService {
|
||||
Utils.debugLog(TAG, "scheduling update because there is good internet");
|
||||
schedule(context);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) { // NOPMD
|
||||
Utils.debugLog(TAG, e.getMessage());
|
||||
}
|
||||
isScheduleIfStillOnWifiRunning = false;
|
||||
|
@ -384,7 +384,7 @@ public final class Utils {
|
||||
}
|
||||
ret = formatter.toString();
|
||||
formatter.close();
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) { // NOPMD
|
||||
Log.w(TAG, "Unable to get certificate fingerprint", e);
|
||||
}
|
||||
return ret;
|
||||
|
Loading…
x
Reference in New Issue
Block a user