Add log messages when dump starts

.. to make it easier to find the right dump file for a test when there
are multiple dump files.
This commit is contained in:
Trustin Lee 2014-12-12 11:54:14 +09:00
parent e72b2235fb
commit 6ee069ffb4

View File

@ -219,7 +219,7 @@ public final class TestUtils {
} }
dumpHeap(heapDumpFile); dumpHeap(heapDumpFile);
dumpStack(threadDumpFile); dumpThreads(threadDumpFile);
} }
private static String timestamp() { private static String timestamp() {
@ -233,6 +233,7 @@ public final class TestUtils {
} }
final String filename = file.toString(); final String filename = file.toString();
logger.info("Dumping heap: {}", filename);
try { try {
hotspotMXBeanDumpHeap.invoke(hotspotMXBean, filename, true); hotspotMXBeanDumpHeap.invoke(hotspotMXBean, filename, true);
} catch (Exception e) { } catch (Exception e) {
@ -240,10 +241,11 @@ public final class TestUtils {
} }
} }
private static void dumpStack(File file) { private static void dumpThreads(File file) {
final String filename = file.toString(); final String filename = file.toString();
OutputStream out = null; OutputStream out = null;
try { try {
logger.info("Dumping threads: {}", filename);
final StringBuilder buf = new StringBuilder(8192); final StringBuilder buf = new StringBuilder(8192);
try { try {
for (ThreadInfo info : ManagementFactory.getThreadMXBean().dumpAllThreads(true, true)) { for (ThreadInfo info : ManagementFactory.getThreadMXBean().dumpAllThreads(true, true)) {