Stop logging when starting the plugin failed.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 15 Oct 2010 13:35:45 +0000 (15:35 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 15 Oct 2010 13:35:45 +0000 (15:35 +0200)
src/main/java/net/pterodactylus/sone/main/SonePlugin.java

index b253d41..810fef1 100644 (file)
@@ -145,8 +145,21 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10
                core.freenetInterface(freenetInterface);
 
                /* start core! */
-               core.start();
-               webInterface.start();
+               boolean startupFailed = true;
+               try {
+                       core.start();
+                       webInterface.start();
+                       startupFailed = false;
+               } finally {
+                       if (startupFailed) {
+                               /*
+                                * we let the exception bubble up but shut the logging down so
+                                * that the logfile is not swamped by the installed logging
+                                * handlers of the failed instances.
+                                */
+                               Logging.shutdown();
+                       }
+               }
        }
 
        /**