From 909d1fd211c1e60c044c1bca81dc4d6a0a622802 Mon Sep 17 00:00:00 2001 From: Florian Zschocke Date: Thu, 7 Nov 2019 23:35:06 +0100 Subject: [PATCH] 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. --- .../java/com/gitblit/servlet/GitblitContext.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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); + } } } -- 2.39.5