Fix behavior when OSHI can't run (#379)

* Fix fallback behavior

* Catch class load errors
This commit is contained in:
opt 2025-07-05 14:32:13 +01:00 committed by GitHub
parent f6baa88cd0
commit a06a8e9cea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -17,7 +17,7 @@ import java.lang.management.ManagementFactory;
import java.net.InetAddress; import java.net.InetAddress;
public final class CommandServerInfo implements CommandExecutor { public final class CommandServerInfo implements CommandExecutor {
private static final @Nullable String[] GPU_DEVICES; private static final String[] GPU_DEVICES;
private static final @Nullable String PROCESSOR_NAME; private static final @Nullable String PROCESSOR_NAME;
static { static {
@ -48,7 +48,7 @@ public final class CommandServerInfo implements CommandExecutor {
); );
if (hardwareInfo == null) { if (hardwareInfo == null) {
GPU_DEVICES = null; GPU_DEVICES = new String[0];
PROCESSOR_NAME = null; PROCESSOR_NAME = null;
} else { } else {
GPU_DEVICES = hardwareInfo.first(); GPU_DEVICES = hardwareInfo.first();
@ -95,7 +95,9 @@ public final class CommandServerInfo implements CommandExecutor {
+ ManagementFactory.getRuntimeMXBean().getVmVersion() + ManagementFactory.getRuntimeMXBean().getVmVersion()
); );
if (PROCESSOR_NAME != null) {
sendInfoMessage(sender, "CPU model", PROCESSOR_NAME); sendInfoMessage(sender, "CPU model", PROCESSOR_NAME);
}
sendInfoMessage(sender, "CPU cores", sendInfoMessage(sender, "CPU cores",
String.valueOf(Runtime.getRuntime().availableProcessors()) String.valueOf(Runtime.getRuntime().availableProcessors())

View file

@ -45,7 +45,7 @@ public final class Utility {
) { ) {
try { try {
return composer.apply(callable.call()); return composer.apply(callable.call());
} catch (Exception e) { } catch (Throwable ex) {
return null; return null;
} }
} }