From c066c9052e99f6fa81305a809a7d3922a2bf02d2 Mon Sep 17 00:00:00 2001 From: vlahoda Date: Wed, 31 Jul 2024 10:50:27 +0200 Subject: [PATCH] Error during application init should stop deployment. Fixes #1072 --- .../java/cz/incad/Kramerius/StartupServlet.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/search/src/java/cz/incad/Kramerius/StartupServlet.java b/search/src/java/cz/incad/Kramerius/StartupServlet.java index 403a62f4b..fb7c6fc18 100644 --- a/search/src/java/cz/incad/Kramerius/StartupServlet.java +++ b/search/src/java/cz/incad/Kramerius/StartupServlet.java @@ -78,8 +78,10 @@ public void init() throws ServletException { * e1.getMessage(),e1); } **/ - Connection connection = this.connectionProvider.get(); + Connection connection = null; try { + connection = this.connectionProvider.get(); + // read previous db version VersionDbInitializer.initDatabase(connection); @@ -110,20 +112,17 @@ public void init() throws ServletException { versionService.updateVersionIfOutdated(); this.pdfService.init(); - } catch (IOException e) { - LOGGER.log(Level.SEVERE, e.getMessage(), e); - } catch (SQLException e) { - LOGGER.log(Level.SEVERE, e.getMessage(), e); + + this.lifecycleRegistry.startNotification(); + } catch (Throwable e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); + throw new RuntimeException("Failed to start Kramerius", e); } finally { if (connection != null) { DatabaseUtils.tryClose(connection); } } - - this.lifecycleRegistry.startNotification(); - } @Override