From 714d2583c4f2799ed4f86eea76aceb8ddeba77e5 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 24 Oct 2016 18:47:47 +1100 Subject: [PATCH] Explicitly log exception from asynchronous tasks. Previously an UnhandledException would be thrown and the stack trace / message would be printed to System.err in the default UncaughtExceptionHandler for ThreadGroup. This was undesirable as it meant that logging frameworks / exception monitors such as Sentry were unable to get the exception. Additionally it would cause the death of the thread in the ExecutorService. This change mimics the behaviour of exceptions occuring during synchronous tasks. By: hibo98 --- .../org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java index f3da84a920..336519c687 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/scheduler/CraftAsyncTask.java @@ -3,12 +3,11 @@ package org.bukkit.craftbukkit.scheduler; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; +import java.util.logging.Level; -import org.apache.commons.lang.UnhandledException; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitWorker; - class CraftAsyncTask extends CraftTask { private final LinkedList workers = new LinkedList(); @@ -53,7 +52,8 @@ class CraftAsyncTask extends CraftTask { super.run(); } catch (final Throwable t) { thrown = t; - throw new UnhandledException( + getOwner().getLogger().log( + Level.WARNING, String.format( "Plugin %s generated an exception while executing task %s", getOwner().getDescription().getFullName(),