From 05d7558873077625260c68bf6e40c52dbf268b32 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 13 Jan 2021 20:30:22 +0000 Subject: [PATCH] Don't print stack trace of FaweExceptions from submitted chunks Addresses #353 --- .../queue/SingleThreadQueueExtent.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java index 25c64cbcf..5f03b4cab 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/beta/implementation/queue/SingleThreadQueueExtent.java @@ -16,11 +16,14 @@ import com.boydti.fawe.beta.implementation.processors.EmptyBatchProcessor; import com.boydti.fawe.beta.implementation.processors.ExtentBatchProcessorHolder; import com.boydti.fawe.beta.implementation.processors.ProcessorScope; import com.boydti.fawe.config.Settings; +import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MemUtil; import com.google.common.util.concurrent.Futures; import com.sk89q.worldedit.extent.Extent; import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ExecutionException; @@ -35,6 +38,9 @@ import java.util.concurrent.locks.ReentrantLock; */ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implements IQueueExtent { + // Don't bother with the full classpath. + private static final Logger log = LoggerFactory.getLogger("SingleThreadQueueExtent"); + // Pool discarded chunks for reuse (can safely be cleared by another thread) // private static final ConcurrentLinkedQueue CHUNK_POOL = new ConcurrentLinkedQueue<>(); // Chunks currently being queued / worked on @@ -291,7 +297,15 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen while (future != null) { future = (Future) future.get(); } - } catch (InterruptedException | ExecutionException e) { + } catch (FaweException messageOnly) { + log.warn(messageOnly.getMessage()); + } catch (ExecutionException e) { + if (e.getCause() instanceof FaweException) { + log.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); + } else { + e.printStackTrace(); + } + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -302,7 +316,15 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen while (first != null) { first = (Future) first.get(); } - } catch (InterruptedException | ExecutionException e) { + } catch (FaweException messageOnly) { + log.warn(messageOnly.getMessage()); + } catch (ExecutionException e) { + if (e.getCause() instanceof FaweException) { + log.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); + } else { + e.printStackTrace(); + } + } catch (InterruptedException e) { e.printStackTrace(); } } @@ -313,7 +335,15 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen if (next.isDone()) { try { next = (Future) next.get(); - } catch (InterruptedException | ExecutionException e) { + } catch (FaweException messageOnly) { + log.warn(messageOnly.getMessage()); + } catch (ExecutionException e) { + if (e.getCause() instanceof FaweException) { + log.warn(e.getCause().getClass().getCanonicalName() + ": " + e.getCause().getMessage()); + } else { + e.printStackTrace(); + } + } catch (InterruptedException e) { e.printStackTrace(); } } else {