From 7410ce9077e0be81b29fd40f6a3cbf784a0238ae Mon Sep 17 00:00:00 2001 From: Minecrell Date: Mon, 9 Jul 2018 01:57:21 +0200 Subject: [PATCH] #2449: Avoid stopping if already in progress Currently it is possible to stop the proxy multiple times, causing the shutdown routines to be called twice. This doesn't make any sense and may even cause problems with some plugins. Cancel early if stopping is already in progress to avoid this. --- proxy/src/main/java/net/md_5/bungee/BungeeCord.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java index d0b98736..fd4c2bf9 100644 --- a/proxy/src/main/java/net/md_5/bungee/BungeeCord.java +++ b/proxy/src/main/java/net/md_5/bungee/BungeeCord.java @@ -379,8 +379,14 @@ public class BungeeCord extends ProxyServer } @Override - public void stop(final String reason) + public synchronized void stop(final String reason) { + if ( !isRunning ) + { + return; + } + isRunning = false; + new Thread( "Shutdown Thread" ) { @Override @@ -388,8 +394,6 @@ public class BungeeCord extends ProxyServer @SuppressWarnings("TooBroadCatch") public void run() { - BungeeCord.this.isRunning = false; - stopListeners(); getLogger().info( "Closing pending connections" );