Catch RejectedExecutionException at UncaughtExceptionHandler and log error instead calling the uncaughtExceptionHandler

Signed-off-by: HenrikJannsen <boilingfrog@gmx.com>
This commit is contained in:
HenrikJannsen 2022-12-27 17:11:38 -05:00
parent 4c237dcf0d
commit e0f4aa281a
No known key found for this signature in database
GPG Key ID: 02AA2BAE387C8307

View File

@ -35,6 +35,7 @@ import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import ch.qos.logback.classic.Level;
@ -72,13 +73,14 @@ public class CommonSetup {
public static void setupUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread
if (throwable.getCause() != null && throwable.getCause().getCause() != null &&
throwable.getCause().getCause() instanceof BlockStoreException) {
log.error(throwable.getMessage());
log.error("Uncaught BlockStoreException ", throwable);
} else if (throwable instanceof ClassCastException &&
"sun.awt.image.BufImgSurfaceData cannot be cast to sun.java2d.xr.XRSurfaceData".equals(throwable.getMessage())) {
log.warn(throwable.getMessage());
} else if (throwable instanceof RejectedExecutionException) {
log.error("Uncaught RejectedExecutionException ", throwable);
} else if (throwable instanceof UnsupportedOperationException &&
"The system tray is not supported on the current platform.".equals(throwable.getMessage())) {
log.warn(throwable.getMessage());