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() {
String path = CustomRuntimeEventLoop.class.getProtectionDomain().getCodeSource().getLocation().toString();
int endIndex = path.lastIndexOf('.');
if (endIndex < 0) {
return "UNKNOWN-VERSION";
}
int startIndex = path.lastIndexOf("/") + 1;
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-", "");
}
catch (Throwable e) {
logger.info("Failed to deterimine framework version");
catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("Failed to detect version", e);
}
return "UNKNOWN-VERSION";
}
}