At the moment, the ThreadDumpEndpoint is not usable in a native image, as GraalVM doesn't implement thread dumping yet.
I've opened an issue for that: https://github.com/oracle/graal/issues/4714
When that issue is resolved, remove the
if (NativeDetector.inNativeImage()) {
throw new ThreadDumperUnavailableException("Running in native image");
}
condition.
Comment From: wilkinsona
We're going to remove the condition now so that the fix is available to users as soon as it has been fixed in Graal.
Comment From: wilkinsona
With the condition removed, a client will receive a 500 response:
HTTP/1.1 500
Connection: close
Content-Type: application/json
Date: Tue, 04 Oct 2022 15:53:34 GMT
Transfer-Encoding: chunked
{
"error": "Internal Server Error",
"path": "/actuator/threaddump",
"status": 500,
"timestamp": "2022-10-04T15:53:34.629+00:00"
}
And the server will log an UnsupportedFeatureError:
com.oracle.svm.core.jdk.UnsupportedFeatureError: ThreadMXBean methods
at com.oracle.svm.core.util.VMError.unsupportedFeature(VMError.java:89) ~[na:na]
at com.oracle.svm.core.jdk.management.SubstrateThreadMXBean.dumpAllThreads(SubstrateThreadMXBean.java:241) ~[na:na]
at org.springframework.boot.actuate.management.ThreadDumpEndpoint.getFormattedThreadDump(ThreadDumpEndpoint.java:51) ~[actuator-webmvc:3.0.0-SNAPSHOT]
at org.springframework.boot.actuate.management.ThreadDumpEndpoint.threadDump(ThreadDumpEndpoint.java:42) ~[actuator-webmvc:3.0.0-SNAPSHOT]
at java.lang.reflect.Method.invoke(Method.java:568) ~[actuator-webmvc:na]
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:281) ~[na:na]
at org.springframework.boot.actuate.endpoint.invoke.reflect.ReflectiveOperationInvoker.invoke(ReflectiveOperationInvoker.java:74) ~[na:na]
at org.springframework.boot.actuate.endpoint.annotation.AbstractDiscoveredOperation.invoke(AbstractDiscoveredOperation.java:60) ~[actuator-webmvc:3.0.0-SNAPSHOT]
…
https://github.com/oracle/graal/issues/4714 is tracking removing the limitation from Graal. Until the Graal issue has been fixed, anyone encountering this problem may want to add 👍 reaction to the issue's opening comment. Once it has been fixed, anyone encountering the problem should check that they are using a version of Graal that contains the fix.