diff --git a/pom.xml b/pom.xml index c03a77d73d..d837e63ee4 100644 --- a/pom.xml +++ b/pom.xml @@ -553,7 +553,7 @@ com.jcraft jzlib - 1.1.2 + 1.1.2 com.ning @@ -710,6 +710,14 @@ 1.8.1 test + + + + org.tukaani + xz + 1.5 + test + diff --git a/testsuite/pom.xml b/testsuite/pom.xml index 73791e6c13..5c137507b9 100644 --- a/testsuite/pom.xml +++ b/testsuite/pom.xml @@ -30,29 +30,9 @@ - junit - junit - - - org.easymock - easymock - - - org.easymock - easymockclassextension - - - org.jmock - jmock-junit4 - - - ch.qos.logback - logback-classic - - - ${project.groupId} - netty-transport-sctp - ${project.version} + ${project.groupId} + netty-transport-sctp + ${project.version} ${project.groupId} @@ -75,6 +55,12 @@ ${os.detected.classifier} true + + + org.tukaani + xz + test + diff --git a/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java b/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java index b326417a2a..6075c8c7fc 100644 --- a/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java +++ b/testsuite/src/test/java/io/netty/testsuite/util/TestUtils.java @@ -20,11 +20,15 @@ import io.netty.util.NetUtil; import io.netty.util.internal.logging.InternalLogger; import io.netty.util.internal.logging.InternalLoggerFactory; import org.junit.rules.TestName; +import org.tukaani.xz.LZMA2Options; +import org.tukaani.xz.XZOutputStream; import javax.management.MBeanServer; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.io.OutputStream; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; @@ -238,6 +242,51 @@ public final class TestUtils { hotspotMXBeanDumpHeap.invoke(hotspotMXBean, filename, true); } catch (Exception e) { logger.warn("Failed to dump heap: {}", filename, e); + return; + } + + final String xzFilename = filename + ".xz"; + logger.info("Compressing the heap dump: {}", xzFilename); + final byte[] buf = new byte[65536]; + InputStream in = null; + OutputStream out = null; + try { + in = new FileInputStream(filename); + out = new XZOutputStream(new FileOutputStream(xzFilename), new LZMA2Options(9)); + for (;;) { + int readBytes = in.read(buf); + if (readBytes < 0) { + break; + } + if (readBytes == 0) { + continue; + } + out.write(buf, 0, readBytes); + } + out.close(); + in.close(); + } catch (Exception e) { + logger.warn("Failed to compress the heap dump: {}", xzFilename, e); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException ignored) { + // Ignore. + } + } + if (out != null) { + try { + out.close(); + } catch (IOException ignored) { + // Ignore. + } + } + } + + // Delete the uncompressed dump in favor of the compressed one. + if (!file.delete()) { + logger.warn("Failed to delete the uncompressed heap dump: {}", filename); } }