From d0be633ed97707435e5c397efb4e4f6b2c8e21a0 Mon Sep 17 00:00:00 2001 From: Devin Ryan Date: Sat, 22 Feb 2014 21:18:44 -0600 Subject: [PATCH] Catch exceptions when abandoning conversions. Fixes BUKKIT-5436 If a conversation is abandoned due to a player disconnecting and an exception is thrown in a ConversationAbandonedListener, the server will crash. This commit prevents the exception from propagating further up the stack and instead just logs the error. --- .../conversations/ConversationTracker.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java b/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java index 1d770a5919..30ef7d9afb 100644 --- a/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java +++ b/src/main/java/org/bukkit/craftbukkit/conversations/ConversationTracker.java @@ -1,11 +1,13 @@ package org.bukkit.craftbukkit.conversations; +import java.util.LinkedList; +import java.util.logging.Level; + +import org.bukkit.Bukkit; import org.bukkit.conversations.Conversation; import org.bukkit.conversations.ConversationAbandonedEvent; import org.bukkit.conversations.ManuallyAbandonedConversationCanceller; -import java.util.LinkedList; - /** */ public class ConversationTracker { @@ -42,8 +44,12 @@ public class ConversationTracker { LinkedList oldQueue = conversationQueue; conversationQueue = new LinkedList(); - for(Conversation conversation : oldQueue) { - conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller())); + for (Conversation conversation : oldQueue) { + try { + conversation.abandon(new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller())); + } catch (Throwable t) { + Bukkit.getLogger().log(Level.SEVERE, "Unexpected exception while abandoning a conversation", t); + } } }