Browse Source

Prevent VirtualThreadSchedulerMXBean problems from breaking /info

At the time of writing, VirtualThreadSchedulerMXBean does not work in
a GraalVM native image (oracle/graal#12802). An attempt to retrieve
the MXBean results in an IllegalArgumentException being thrown. This
causes a failure when serializing ProcessInfo to JSON, breaking the
Actuator's info endpoint when management.info.process.enabled=true.

This commit updates ProcessInfo to be more defensive when working
with the MXBean. Now, if any exception is thrown, null will be
returned for the virtual threads info. This approach should allow the
functionality to work whenever a fix is made in Graal without
requiring further changes in Boot.

Fixes gh-48810
3.5.x
Andy Wilkinson 1 week ago
parent
commit
d9fa9353aa
  1. 2
      spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/ProcessInfo.java

2
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/ProcessInfo.java

@ -108,7 +108,7 @@ public class ProcessInfo { @@ -108,7 +108,7 @@ public class ProcessInfo {
int poolSize = invokeMethod(mxbeanClass, mxbean, "getPoolSize");
return new VirtualThreadsInfo(mountedVirtualThreadCount, queuedVirtualThreadCount, parallelism, poolSize);
}
catch (ReflectiveOperationException ex) {
catch (Exception ex) {
return null;
}
}

Loading…
Cancel
Save