Skip to content

Commit 80b1f9c

Browse files
committed
Merge branch 'main' into 4.0.x
2 parents 4d349ec + 01cb25e commit 80b1f9c

File tree

1 file changed

+16
-4
lines changed
  • spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management

1 file changed

+16
-4
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.nio.file.Files;
3030
import java.time.LocalDateTime;
3131
import java.time.format.DateTimeFormatter;
32+
import java.util.Locale;
3233
import java.util.concurrent.TimeUnit;
3334
import java.util.concurrent.locks.Lock;
3435
import java.util.concurrent.locks.ReentrantLock;
@@ -47,6 +48,7 @@
4748
import org.springframework.util.Assert;
4849
import org.springframework.util.ClassUtils;
4950
import org.springframework.util.ReflectionUtils;
51+
import org.springframework.util.StringUtils;
5052

5153
/**
5254
* Web {@link Endpoint @Endpoint} to expose heap dumps.
@@ -112,12 +114,22 @@ private Resource dumpHeap(Boolean live) throws IOException, InterruptedException
112114
* @throws HeapDumperUnavailableException if the heap dumper cannot be created
113115
*/
114116
protected HeapDumper createHeapDumper() throws HeapDumperUnavailableException {
115-
try {
116-
return new HotSpotDiagnosticMXBeanHeapDumper();
117-
}
118-
catch (HeapDumperUnavailableException ex) {
117+
if (isRunningOnOpenJ9()) {
119118
return new OpenJ9DiagnosticsMXBeanHeapDumper();
120119
}
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;
121133
}
122134

123135
/**

0 commit comments

Comments
 (0)