JvmInformation#getJavaVersion may now crash

This commit is contained in:
JeremyStar™ 2024-06-27 20:09:43 +02:00
parent cc3cd52d22
commit 5c1fba4ef6
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -19,6 +19,9 @@
package de.staropensource.sosengine.base.data.info; package de.staropensource.sosengine.base.data.info;
import de.staropensource.sosengine.base.logging.Logger;
import de.staropensource.sosengine.base.types.CodePart;
import de.staropensource.sosengine.base.classes.logging.LogIssuer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
@ -52,7 +55,12 @@ public final class JvmInformation {
version = version.substring(0, version.indexOf(".")); version = version.substring(0, version.indexOf("."));
} }
return Integer.parseInt(version); try {
return Integer.parseInt(version);
} catch (NumberFormatException exception) {
Logger.crash(new LogIssuer(JvmInformation.class, CodePart.ENGINE), "Could not parse Java version: Integer conversion failed for string \"" + version + "\"");
return Integer.MAX_VALUE;
}
} }
/** /**