|
29 | 29 | import java.nio.file.Files;
|
30 | 30 | import java.time.LocalDateTime;
|
31 | 31 | import java.time.format.DateTimeFormatter;
|
| 32 | +import java.util.Locale; |
32 | 33 | import java.util.concurrent.TimeUnit;
|
33 | 34 | import java.util.concurrent.locks.Lock;
|
34 | 35 | import java.util.concurrent.locks.ReentrantLock;
|
|
47 | 48 | import org.springframework.util.Assert;
|
48 | 49 | import org.springframework.util.ClassUtils;
|
49 | 50 | import org.springframework.util.ReflectionUtils;
|
| 51 | +import org.springframework.util.StringUtils; |
50 | 52 |
|
51 | 53 | /**
|
52 | 54 | * Web {@link Endpoint @Endpoint} to expose heap dumps.
|
@@ -112,12 +114,22 @@ private Resource dumpHeap(Boolean live) throws IOException, InterruptedException
|
112 | 114 | * @throws HeapDumperUnavailableException if the heap dumper cannot be created
|
113 | 115 | */
|
114 | 116 | protected HeapDumper createHeapDumper() throws HeapDumperUnavailableException {
|
115 |
| - try { |
116 |
| - return new HotSpotDiagnosticMXBeanHeapDumper(); |
117 |
| - } |
118 |
| - catch (HeapDumperUnavailableException ex) { |
| 117 | + if (isRunningOnOpenJ9()) { |
119 | 118 | return new OpenJ9DiagnosticsMXBeanHeapDumper();
|
120 | 119 | }
|
| 120 | + return new HotSpotDiagnosticMXBeanHeapDumper(); |
| 121 | + } |
| 122 | + |
| 123 | + private boolean isRunningOnOpenJ9() { |
| 124 | + String vmName = System.getProperty("java.vm.name"); |
| 125 | + if (StringUtils.hasLength(vmName) && vmName.toLowerCase(Locale.ROOT).contains("openj9")) { |
| 126 | + return true; |
| 127 | + } |
| 128 | + String vmVendor = System.getProperty("java.vm.vendor"); |
| 129 | + if (StringUtils.hasLength(vmVendor) && vmVendor.toLowerCase(Locale.ROOT).contains("openj9")) { |
| 130 | + return true; |
| 131 | + } |
| 132 | + return false; |
121 | 133 | }
|
122 | 134 |
|
123 | 135 | /**
|
|
0 commit comments