From 3f634974bcdbd0a9cbb3825a6cd1c3decaacc702 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sat, 22 Jan 2022 23:22:42 +0100 Subject: [PATCH] Reduce log-presence of the ClassNotFound error for RemovelCause on forge --- .../de/bluecolored/bluemap/core/BlueMap.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java index ee80baad..b66d5766 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java @@ -24,20 +24,15 @@ */ package de.bluecolored.bluemap.core; -import com.github.benmanes.caffeine.cache.RemovalCause; import de.bluecolored.bluemap.core.logger.Logger; import org.spongepowered.configurate.ConfigurationNode; import org.spongepowered.configurate.gson.GsonConfigurationLoader; import java.io.IOException; -import java.util.UUID; import java.util.concurrent.ForkJoinPool; public class BlueMap { - // early-loading this class, to fix a classloading issue - private static final RemovalCause RC = null; - public static final String VERSION, GIT_HASH, GIT_CLEAN; static { String version = "DEV", gitHash = "DEV", gitClean = "DEV"; @@ -63,6 +58,17 @@ public class BlueMap { GIT_CLEAN = gitClean; } - public static final ForkJoinPool THREAD_POOL = new ForkJoinPool(); + public static final ForkJoinPool THREAD_POOL = new ForkJoinPool( + Runtime.getRuntime().availableProcessors(), + ForkJoinPool.defaultForkJoinWorkerThreadFactory, + (thread, ex) -> { + if (ex instanceof ClassNotFoundException && ex.getMessage().contains("RemovalCause")) { + Logger.global.noFloodWarning("RemovalCauseError", ex.getMessage()); + } else { + Logger.global.logError("Something went wrong!", ex); + } + }, + false + ); }