From 2f9d7406125a88e8ce808577ec104f899453d745 Mon Sep 17 00:00:00 2001 From: Roman Szturc Date: Fri, 15 Nov 2024 10:08:55 +0100 Subject: [PATCH] Endpoint /versions improved --- CHANGELOG.md | 3 +++ pom.xml | 2 +- .../remrem/generate/controller/VersionService.java | 12 +++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7b37e9..415718b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.1.15 +- Endpoint /versions made more robust. + ## 2.1.14 - Made changes to /generate end-point to improve efficiency how result of event generation is handled diff --git a/pom.xml b/pom.xml index 76c4add..f2cb743 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ - 2.1.14 + 2.1.15 2.2.7 eiffel-remrem-generate diff --git a/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/VersionService.java b/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/VersionService.java index 7617d32..cfc2988 100644 --- a/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/VersionService.java +++ b/service/src/main/java/com/ericsson/eiffel/remrem/generate/controller/VersionService.java @@ -110,7 +110,17 @@ public Map> getMessagingVersions() { */ public Map getServiceVersion() { String resourcesPath = this.getClass().getClassLoader().getResource("").getPath(); - String manifestPath = resourcesPath.substring(0, resourcesPath.lastIndexOf(WEB_INF)).concat(META_INF_MANIFEST_MF); + int indexWebInf = resourcesPath.lastIndexOf(WEB_INF); + if (indexWebInf == -1) { + // "WEB-INF" was not found in the path, strange... + log.error("Cannot find '" + WEB_INF + "' in the path '" + resourcesPath + + "'. Not loaded from a WAR file?"); + serviceVersion.put(VERSION, "\"ERROR: " + META_INF_MANIFEST_MF + + " not found; was the service run from a WAR file?\""); + return serviceVersion; + } + + String manifestPath = resourcesPath.substring(0, indexWebInf).concat(META_INF_MANIFEST_MF); try { Manifest manifest = new Manifest(new FileInputStream(manifestPath)); Attributes mainAttribs = manifest.getMainAttributes();