apache/shenyu · warning · ShenyuException
Error retrieving system information: " + e.getMessage()
Error message
Error retrieving system information: " + e.getMessage()
What it means
SystemInfoUtils.getSystemInfo collects OS/Java runtime metrics (processors, memory) via OperatingSystemMXBean and returns them as JSON. Any exception during metric collection is wrapped in ShenyuException 'Error retrieving system information: <message>'.
Solutions
- Upgrade/verify the JDK supports com.sun.management.OperatingSystemMXBean methods used (Java 14+ renamed get{Total,Free}PhysicalMemorySize variants).
- Catch and degrade gracefully: return partial system info instead of throwing.
- Run on a supported platform/JDK combination matching ShenYu's requirements (Java 17).
- Inspect the wrapped message (e.getMessage) to identify the specific MXBean call that failed.
Example fix
// before
String info = SystemInfoUtils.getSystemInfo(); // may throw
// after
String info;
try {
info = SystemInfoUtils.getSystemInfo();
} catch (Exception e) {
LOG.warn("system info unavailable: {}", e.getMessage());
info = "{}";
} Defensive patterns
Strategy: fallback
Try / catch
try { String info = SystemInfoUtils.getSystemInfo(); } catch (ShenyuException e) { LOG.warn("system info unavailable: {}", e.getMessage()); info = "{}"; } Prevention
- Run on a JDK matching ShenYu requirements (Java 17)
- Return degraded/empty JSON instead of failing monitoring calls
- Wrap MXBean access in feature detection
- Test on containerized and bare-metal environments
When it happens
Trigger: Calling getSystemInfo on a JVM/platform where the MXBean methods (getTotalMemorySize, etc.) are unavailable or throw, or when JSON serialization of the collected map fails.
Common situations: Running on an older JDK where the OS bean method names differ (com.sun.management.OperatingSystemMXBean API changes); restricted containers blocking MXBean access; custom MBean server setups.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- args.length < types.length
- build json response message is error, newBuilder method is…
- can not get defaultInstance Field of
- can not get fullMethodName Field of
- Could not find field [" + fieldName + "] on target [" + obj…
AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12).
Data as JSON: /api/errors/119e1ec14b0fdadf.
Report an issue: GitHub.
Appendix: source
Thrown at shenyu-common/src/main/java/org/apache/shenyu/common/utils/SystemInfoUtils.java:72
*/
public static String getSystemInfo() {
try {
// Get host information using OSHI
SystemInfo systemInfo = new SystemInfo();
// Get host information
OperatingSystemMXBean osBean =
(OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
Map<String, Object> hostInfo = Map.of(
ARCH, osBean.getArch(),
OPERATING_SYSTEM, systemInfo.getOperatingSystem().toString(),
AVAILABLE_PROCESSORS, osBean.getAvailableProcessors(),
TOTAL_MEMORY_SIZE_GB, bytesToGB(osBean.getTotalMemorySize()) + GB
);
return GsonUtils.getInstance().toJson(hostInfo);
} catch (Exception e) {
// Handle any exceptions that may occur
throw new ShenyuException("Error retrieving system information: " + e.getMessage());
}
}
/**
* Bytes to gb double.
*
* @param bytesValue the bytes value
* @return the double
*/
private static double bytesToGB(final long bytesValue) {
return BigDecimal.valueOf(bytesValue / (double) BYTES_IN_GB)
.setScale(DECIMAL_PLACES, ROUNDING_MODE)
.doubleValue();
}
}
View on GitHub (pinned to 567142e072)