GH-995 Wrapped SCF version discovery in AWS Custom Runtime with try/catch

Resolves #995
This commit is contained in:
Oleg Zhurakousky
2023-03-01 13:01:02 +01:00
parent bb9fda2fc0
commit 38411d424b

View File

@@ -266,17 +266,19 @@ public final class CustomRuntimeEventLoop implements SmartLifecycle {
} }
private static String extractVersion() { private static String extractVersion() {
String path = CustomRuntimeEventLoop.class.getProtectionDomain().getCodeSource().getLocation().toString();
int endIndex = path.lastIndexOf('.');
if (endIndex < 0) {
return "UNKNOWN-VERSION";
}
int startIndex = path.lastIndexOf("/") + 1;
try { try {
String path = CustomRuntimeEventLoop.class.getProtectionDomain().getCodeSource().getLocation().toString();
int endIndex = path.lastIndexOf('.');
if (endIndex < 0) {
return "UNKNOWN-VERSION";
}
int startIndex = path.lastIndexOf("/") + 1;
return path.substring(startIndex, endIndex).replace("spring-cloud-function-adapter-aws-", ""); return path.substring(startIndex, endIndex).replace("spring-cloud-function-adapter-aws-", "");
} }
catch (Throwable e) { catch (Exception e) {
logger.info("Failed to deterimine framework version"); if (logger.isDebugEnabled()) {
logger.debug("Failed to detect version", e);
}
return "UNKNOWN-VERSION"; return "UNKNOWN-VERSION";
} }
} }