From 4a2709185bd7ba84c3230cb94d4efea940681742 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 4 Nov 2022 09:11:45 -0500 Subject: [PATCH] fix: avoid NPE when configuration is missing #2857 (#2863) --- .../jans/agama/engine/service/AppInitializer.java | 10 ++-------- .../jans/agama/engine/service/ServicesFactory.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/agama/engine/src/main/java/io/jans/agama/engine/service/AppInitializer.java b/agama/engine/src/main/java/io/jans/agama/engine/service/AppInitializer.java index 0d2ff1fb84c..95f21203e91 100644 --- a/agama/engine/src/main/java/io/jans/agama/engine/service/AppInitializer.java +++ b/agama/engine/src/main/java/io/jans/agama/engine/service/AppInitializer.java @@ -9,13 +9,8 @@ import jakarta.enterprise.event.Observes; import jakarta.inject.Inject; -import org.slf4j.Logger; - @ApplicationScoped public class AppInitializer { - - @Inject - private Logger logger; @Inject private Transpilation trTimer; @@ -25,11 +20,10 @@ public class AppInitializer { public void run(@Observes @ApplicationInitialized(ApplicationScoped.class) ApplicationInitializedEvent event) { - - logger.info("Initializing Agama services"); + trTimer.initTimer(); fcleaner.initTimer(); } - + } diff --git a/agama/engine/src/main/java/io/jans/agama/engine/service/ServicesFactory.java b/agama/engine/src/main/java/io/jans/agama/engine/service/ServicesFactory.java index 55d43d3431b..62cfc9bc711 100644 --- a/agama/engine/src/main/java/io/jans/agama/engine/service/ServicesFactory.java +++ b/agama/engine/src/main/java/io/jans/agama/engine/service/ServicesFactory.java @@ -43,9 +43,16 @@ public EngineConfig engineConfigInstance() { public void updateConfiguration(@Observes @ConfigurationUpdate AppConfiguration appConfiguration) { try { - logger.info("Refreshing Agama configuration..."); - BeanUtils.copyProperties(econfig, appConfiguration.getAgamaConfiguration()); - serializerFactory.refresh(); + EngineConfig newConfig = appConfiguration.getAgamaConfiguration(); + + if (newConfig == null) { + logger.info("Agama will not be available in this deployment"); + + } else { + logger.info("Refreshing Agama configuration..."); + BeanUtils.copyProperties(econfig, newConfig); + serializerFactory.refresh(); + } } catch (Exception e) { logger.error(e.getMessage(), e); }