Bug 535730 - Add postfix 'hprof' to Virgo heap dumps
Since Java 8 8u141 Update heap dump names have to end with the prefix
`hprof`.
diff --git a/build.gradle b/build.gradle
index 0ba2942..d22a05d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -403,8 +403,6 @@
if (System.properties['ci.build'] == 'true') {
ignoreFailures = true
}
- // Since JDK 8u141 heap dump names are required to have the suffix 'hprof' @see Bug 535730
- systemProperty "jdk.management.heapdump.allowAnyFileSuffix", "true"
}
configurations { ecj {} }
diff --git a/medic/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/dump/impl/heap/HeapDumpContributor.java b/medic/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/dump/impl/heap/HeapDumpContributor.java
index 4083594..50c0b73 100644
--- a/medic/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/dump/impl/heap/HeapDumpContributor.java
+++ b/medic/org.eclipse.virgo.medic.core/src/main/java/org/eclipse/virgo/medic/dump/impl/heap/HeapDumpContributor.java
@@ -53,7 +53,6 @@
Method method = managementFactoryClass.getMethod("getDiagnosticMXBean");
diagnosticMBean = method.invoke(null);
} catch (Exception e) {
- heapDumpMethod = null;
diagnosticMBean = null;
}
}
@@ -62,7 +61,6 @@
try {
heapDumpMethod = diagnosticMBean.getClass().getMethod("dumpHeap", String.class, boolean.class);
} catch (Exception e) {
- heapDumpMethod = null;
diagnosticMBean = null;
}
}
@@ -74,23 +72,13 @@
public void contribute(Dump dump) throws DumpContributionFailedException {
try {
if (this.heapDumpMethod != null && this.diagnosticMBean != null) {
- heapDumpMethod.invoke(this.diagnosticMBean, dump.createFile("heap.out").getAbsolutePath(), true);
+ heapDumpMethod.invoke(this.diagnosticMBean, dump.createFile("heap.out.hprof").getAbsolutePath(), true);
} else {
- PrintWriter writer = null;
- try {
- writer = new PrintWriter(dump.createFileWriter("heap.err"));
+ try (PrintWriter writer = new PrintWriter(dump.createFileWriter("heap.err.hprof"))) {
writer.println("Diagnostic MXBean is not available. Heap dump cannot be generated.");
- } finally {
- if (writer != null) {
- writer.close();
- }
}
}
- } catch (InvocationTargetException e) {
- throw new DumpContributionFailedException("Failed to generate heap dump contribution", e);
- } catch (IllegalArgumentException e) {
- throw new DumpContributionFailedException("Failed to generate heap dump contribution", e);
- } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException | IllegalArgumentException | IllegalAccessException e) {
throw new DumpContributionFailedException("Failed to generate heap dump contribution", e);
}
}
diff --git a/medic/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java b/medic/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java
index d6a8ad6..acb4f8c 100644
--- a/medic/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java
+++ b/medic/org.eclipse.virgo.medic.core/src/test/java/org/eclipse/virgo/medic/dump/impl/HeapDumpContributorTests.java
@@ -64,11 +64,10 @@
try {
Class.forName("sun.management.ManagementFactory").getMethod("getDiagnosticMXBean");
diagnostMbeanAvailable = true;
- } catch (Exception e) {
- diagnostMbeanAvailable = false;
+ } catch (Exception ignored) {
}
}
- assertEquals(diagnostMbeanAvailable, new File(this.dumpDirectory.getRoot(), "heap.out").exists());
+ assertEquals(diagnostMbeanAvailable, new File(this.dumpDirectory.getRoot(), "heap.out.hprof").exists());
}
}
diff --git a/medic/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/dump/test/DumpIntegrationTests.java b/medic/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/dump/test/DumpIntegrationTests.java
index af8f2aa..6b1a71c 100644
--- a/medic/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/dump/test/DumpIntegrationTests.java
+++ b/medic/org.eclipse.virgo.medic.integrationtest/src/test/java/org/eclipse/virgo/medic/dump/test/DumpIntegrationTests.java
@@ -92,7 +92,7 @@
assertDumpContributionsNumberOf(file.listFiles()[0], 3);
assertDumpContributionsEssential(file.listFiles()[0], "summary.txt", "thread.txt");
- assertDumpContributionsAllowable(file.listFiles()[0], "heap.out", "heap.err", "summary.txt", "thread.txt");
+ assertDumpContributionsAllowable(file.listFiles()[0], "heap.out.hprof", "heap.err", "summary.txt", "thread.txt");
properties.put("dump.root.directory", "build/dumps/2");
@@ -109,7 +109,7 @@
assertDumpContributionsNumberOf(file.listFiles()[0], 3);
assertDumpContributionsEssential(file.listFiles()[0], "summary.txt", "thread.txt");
- assertDumpContributionsAllowable(file.listFiles()[0], "heap.out", "heap.err", "summary.txt", "thread.txt");
+ assertDumpContributionsAllowable(file.listFiles()[0], "heap.out.hprof", "heap.err.hprof", "summary.txt", "thread.txt");
}
@@ -167,7 +167,7 @@
assertDumpContributionsNumberOf(file.listFiles()[0], 3);
assertDumpContributionsEssential(file.listFiles()[0], "summary.txt", "thread.txt");
- assertDumpContributionsAllowable(file.listFiles()[0], "heap.out", "heap.err", "summary.txt", "thread.txt");
+ assertDumpContributionsAllowable(file.listFiles()[0], "heap.out.hprof", "heap.err.hprof", "summary.txt", "thread.txt");
}
private Configuration getConfiguration(String pid) throws IOException {
diff --git a/packaging/kernel/src/main/dist/bin/dmk.bat b/packaging/kernel/src/main/dist/bin/dmk.bat
index 67f6e78..7b3346f 100644
--- a/packaging/kernel/src/main/dist/bin/dmk.bat
+++ b/packaging/kernel/src/main/dist/bin/dmk.bat
@@ -176,7 +176,6 @@
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:+HeapDumpOnOutOfMemoryError
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:ErrorFile="%KERNEL_HOME%\serviceability\error.log"
- set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Djdk.management.heapdump.allowAnyFileSuffix=true
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:HeapDumpPath="%KERNEL_HOME%\serviceability\heap_dump.hprof"
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Djava.security.auth.login.config="%CONFIG_DIR%\org.eclipse.virgo.kernel.authentication.config"
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Dorg.eclipse.virgo.kernel.authentication.file="%CONFIG_DIR%\org.eclipse.virgo.kernel.users.properties"
diff --git a/packaging/kernel/src/main/filtered/bin/dmk.sh b/packaging/kernel/src/main/filtered/bin/dmk.sh
index 0937afb..d4fe9e2 100755
--- a/packaging/kernel/src/main/filtered/bin/dmk.sh
+++ b/packaging/kernel/src/main/filtered/bin/dmk.sh
@@ -186,8 +186,7 @@
$JMX_OPTS \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:ErrorFile="$KERNEL_HOME/serviceability/error.log" \
- -Djdk.management.heapdump.allowAnyFileSuffix=true \
- -XX:HeapDumpPath="$KERNEL_HOME/serviceability/heap_dump.hprof" \
+ -XX:HeapDumpPath="$KERNEL_HOME/serviceability/heap_dump.hprof" \
-Djava.security.auth.login.config="$AUTH_LOGIN" \
-Dorg.eclipse.virgo.kernel.authentication.file="$AUTH_FILE" \
-Djava.io.tmpdir="$TMP_DIR" \
diff --git a/packaging/nano/src/main/dist/bin/dmk.bat b/packaging/nano/src/main/dist/bin/dmk.bat
index 67f6e78..7b3346f 100644
--- a/packaging/nano/src/main/dist/bin/dmk.bat
+++ b/packaging/nano/src/main/dist/bin/dmk.bat
@@ -176,7 +176,6 @@
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:+HeapDumpOnOutOfMemoryError
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:ErrorFile="%KERNEL_HOME%\serviceability\error.log"
- set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Djdk.management.heapdump.allowAnyFileSuffix=true
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:HeapDumpPath="%KERNEL_HOME%\serviceability\heap_dump.hprof"
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Djava.security.auth.login.config="%CONFIG_DIR%\org.eclipse.virgo.kernel.authentication.config"
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Dorg.eclipse.virgo.kernel.authentication.file="%CONFIG_DIR%\org.eclipse.virgo.kernel.users.properties"
diff --git a/packaging/nano/src/main/filtered/bin/dmk.sh b/packaging/nano/src/main/filtered/bin/dmk.sh
index 0937afb..54d33e1 100755
--- a/packaging/nano/src/main/filtered/bin/dmk.sh
+++ b/packaging/nano/src/main/filtered/bin/dmk.sh
@@ -186,7 +186,6 @@
$JMX_OPTS \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:ErrorFile="$KERNEL_HOME/serviceability/error.log" \
- -Djdk.management.heapdump.allowAnyFileSuffix=true \
-XX:HeapDumpPath="$KERNEL_HOME/serviceability/heap_dump.hprof" \
-Djava.security.auth.login.config="$AUTH_LOGIN" \
-Dorg.eclipse.virgo.kernel.authentication.file="$AUTH_FILE" \
diff --git a/packaging/tomcat-server/src/main/dist/bin/dmk.bat b/packaging/tomcat-server/src/main/dist/bin/dmk.bat
index 67f6e78..7b3346f 100644
--- a/packaging/tomcat-server/src/main/dist/bin/dmk.bat
+++ b/packaging/tomcat-server/src/main/dist/bin/dmk.bat
@@ -176,7 +176,6 @@
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:+HeapDumpOnOutOfMemoryError
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:ErrorFile="%KERNEL_HOME%\serviceability\error.log"
- set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Djdk.management.heapdump.allowAnyFileSuffix=true
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -XX:HeapDumpPath="%KERNEL_HOME%\serviceability\heap_dump.hprof"
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Djava.security.auth.login.config="%CONFIG_DIR%\org.eclipse.virgo.kernel.authentication.config"
set KERNEL_JAVA_PARMS=%KERNEL_JAVA_PARMS% -Dorg.eclipse.virgo.kernel.authentication.file="%CONFIG_DIR%\org.eclipse.virgo.kernel.users.properties"
diff --git a/packaging/tomcat-server/src/main/filtered/bin/dmk.sh b/packaging/tomcat-server/src/main/filtered/bin/dmk.sh
index 0937afb..d4fe9e2 100755
--- a/packaging/tomcat-server/src/main/filtered/bin/dmk.sh
+++ b/packaging/tomcat-server/src/main/filtered/bin/dmk.sh
@@ -186,8 +186,7 @@
$JMX_OPTS \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:ErrorFile="$KERNEL_HOME/serviceability/error.log" \
- -Djdk.management.heapdump.allowAnyFileSuffix=true \
- -XX:HeapDumpPath="$KERNEL_HOME/serviceability/heap_dump.hprof" \
+ -XX:HeapDumpPath="$KERNEL_HOME/serviceability/heap_dump.hprof" \
-Djava.security.auth.login.config="$AUTH_LOGIN" \
-Dorg.eclipse.virgo.kernel.authentication.file="$AUTH_FILE" \
-Djava.io.tmpdir="$TMP_DIR" \