Class DumpsManager
/threaddump, /heapdump).
Both the *Mixin and *Resource flavors delegate here so the two forms cannot drift —
the same shared-worker pattern the health and metrics surfaces use.
Thread dump is rendered from the JDK-standard ThreadMXBean (always available).
Heap dump is produced via the HotSpot HotSpotDiagnosticMXBean#dumpHeap(String,boolean)
method, invoked reflectively so this module carries no compile-time dependency on
com.sun.management — on a non-HotSpot JVM the heap dump degrades cleanly (the endpoints
surface that as HTTP 501).
Exposure is governed by DumpsSettings resolved from the bean store; both dumps are
deny-by-default — see DumpsSettings.
See Also:
- Since:
- 10.0.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWrites a heap dump (hprof) to the supplied file via the HotSpotHotSpotDiagnosticMXBean.heapDumpStream(boolean live) Produces a heap dump and returns it as a self-deleting input stream.resolveSettings(RestContext context) Resolves theDumpsSettingsfrom the host context's bean store, falling back to the deny-all default.Renders a full thread dump from theThreadMXBean.
-
Constructor Details
-
DumpsManager
public DumpsManager()
-
-
Method Details
-
resolveSettings
Resolves theDumpsSettingsfrom the host context's bean store, falling back to the deny-all default.- Parameters:
context- The REST context whose bean store is searched. May benull .- Returns:
- The registered settings, or
DumpsSettings.DEFAULTwhen none is registered.
-
threadDump
Renders a full thread dump from theThreadMXBean.- Returns:
- A human-readable thread dump (never
null or empty).
-
heapDump
Writes a heap dump (hprof) to the supplied file via the HotSpotHotSpotDiagnosticMXBean.Invoked reflectively to avoid a compile-time dependency on
com.sun.management. The target file must not already exist (adumpHeaprequirement).- Parameters:
target- The hprof output file. Must not benull (and must not pre-exist).live- Iftrue , dump only live (reachable) objects.- Returns:
true if the dump was written;false if this JVM has no HotSpot heap-dump support (the endpoints surface that as HTTP 501).
-
heapDumpStream
Produces a heap dump and returns it as a self-deleting input stream.Writes the hprof to a fresh temp file (the
dumpHeapno-pre-existing-file requirement is satisfied by deleting the just-created temp file before the dump), then returns a stream over it that deletes the backing file when closed.- Parameters:
live- Iftrue , dump only live (reachable) objects.- Returns:
- A stream over the hprof file, or
null if this JVM has no HotSpot heap-dump support. - Throws:
IOException- If the temp file could not be created or opened.
-