From: Florian Zschocke Date: Thu, 7 Nov 2019 22:35:06 +0000 (+0100) Subject: Fix NullpointerException when stopping GitBlit Server. X-Git-Tag: r1.9.0~30 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=909d1fd211c1e60c044c1bca81dc4d6a0a622802;p=gitblit.git Fix NullpointerException when stopping GitBlit Server. When GitBlit server did not start properly, is running but couldn't start the `PluginManager`, then stopping the server via the `--stop` argument on the command line resulted in a NullpointerException. Which left the server running. Now this is prevented and the server will actually shut down. --- diff --git a/src/main/java/com/gitblit/servlet/GitblitContext.java b/src/main/java/com/gitblit/servlet/GitblitContext.java index 750da796..cd8615a8 100644 --- a/src/main/java/com/gitblit/servlet/GitblitContext.java +++ b/src/main/java/com/gitblit/servlet/GitblitContext.java @@ -293,11 +293,13 @@ public class GitblitContext extends GuiceServletContextListener { logger.info("Gitblit context destroyed by servlet container."); IPluginManager pluginManager = getManager(IPluginManager.class); - for (LifeCycleListener listener : pluginManager.getExtensions(LifeCycleListener.class)) { - try { - listener.onShutdown(); - } catch (Throwable t) { - logger.error(null, t); + if (pluginManager != null) { + for (LifeCycleListener listener : pluginManager.getExtensions(LifeCycleListener.class)) { + try { + listener.onShutdown(); + } catch (Throwable t) { + logger.error(null, t); + } } }