From 10558b2682dcbf254c4880942b61cb2c611b60ac Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 11 Dec 2025 22:39:46 -0800 Subject: [PATCH] GUACAMOLE-2181: Avoid NPE if servlet container is shut down before extensions are loaded. --- .../GuacamoleServletContextListener.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/guacamole/src/main/java/org/apache/guacamole/GuacamoleServletContextListener.java b/guacamole/src/main/java/org/apache/guacamole/GuacamoleServletContextListener.java index aef48592a..99db0b9fd 100644 --- a/guacamole/src/main/java/org/apache/guacamole/GuacamoleServletContextListener.java +++ b/guacamole/src/main/java/org/apache/guacamole/GuacamoleServletContextListener.java @@ -297,13 +297,15 @@ public class GuacamoleServletContextListener extends GuiceServletContextListener } // Inform any listeners that application shutdown has completed - try { - listenerService.handleEvent(new ApplicationShutdownEvent() { - // The application shutdown event currently has no content - }); - } - catch (GuacamoleException e) { - logger.error("An extension listening for application shutdown failed: {}", e.getMessage(), e); + if (listenerService != null) { + try { + listenerService.handleEvent(new ApplicationShutdownEvent() { + // The application shutdown event currently has no content + }); + } + catch (GuacamoleException e) { + logger.error("An extension listening for application shutdown failed: {}", e.getMessage(), e); + } } }