From aa28742fddb99d7c5dc61b32b9f0a973ed2898f1 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 9 Nov 2005 17:31:16 +0000 Subject: [PATCH] more sigar.close for dmalloc --- bindings/java/src/net/hyperic/sigar/cmd/Shell.java | 3 +++ bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java | 6 ++++++ bindings/java/src/net/hyperic/sigar/test/TestInvoker.java | 2 ++ bindings/java/src/net/hyperic/sigar/test/TestLog.java | 1 + bindings/java/src/net/hyperic/sigar/test/TestProcTime.java | 2 ++ bindings/java/src/net/hyperic/sigar/test/TestThreadCpu.java | 2 +- 6 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java index 01d810a1..6444ef73 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java @@ -20,7 +20,9 @@ import net.hyperic.sigar.shell.ShellCommandHandler; import net.hyperic.sigar.shell.ShellCommandInitException; import net.hyperic.sigar.shell.ShellCommandUsageException; +import net.hyperic.sigar.test.SigarTestCase; import net.hyperic.sigar.test.SigarTestRunner; + import net.hyperic.sigar.util.Getline; /** @@ -166,6 +168,7 @@ public class Shell extends ShellBase { public void shutdown() { this.sigar.close(); + SigarTestCase.closeSigar(); //shutup dmalloc super.shutdown(); } diff --git a/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java b/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java index db1bc6de..59547798 100644 --- a/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java +++ b/bindings/java/src/net/hyperic/sigar/test/SigarTestCase.java @@ -52,6 +52,12 @@ public abstract class SigarTestCase extends TestCase { return sigar; } + public static void closeSigar() { + if (sigar != null) { + sigar.close(); + } + } + public Properties getProperties() { return this.props; } diff --git a/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java b/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java index 7731a134..f2232024 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestInvoker.java @@ -56,6 +56,8 @@ public class TestInvoker extends SigarTestCase { SigarProxyCache.newInstance(sigar); testOK(proxy); + + sigar.close(); } private void testOK(SigarProxy proxy) throws Exception { diff --git a/bindings/java/src/net/hyperic/sigar/test/TestLog.java b/bindings/java/src/net/hyperic/sigar/test/TestLog.java index dfccaedf..a1182b99 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestLog.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestLog.java @@ -13,5 +13,6 @@ public class TestLog extends SigarTestCase { sigar.enableLogging(true); sigar.enableLogging(false); sigar.enableLogging(true); + sigar.close(); } } diff --git a/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java b/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java index 1800270e..019e7d01 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestProcTime.java @@ -32,5 +32,7 @@ public class TestProcTime extends SigarTestCase { assertGtEqZeroTrace("Sys", procTime.getSys()); assertGtEqZeroTrace("Total", procTime.getTotal()); + + sigar.close(); } } diff --git a/bindings/java/src/net/hyperic/sigar/test/TestThreadCpu.java b/bindings/java/src/net/hyperic/sigar/test/TestThreadCpu.java index 71fd4272..dbbc15d7 100644 --- a/bindings/java/src/net/hyperic/sigar/test/TestThreadCpu.java +++ b/bindings/java/src/net/hyperic/sigar/test/TestThreadCpu.java @@ -12,7 +12,7 @@ public class TestThreadCpu extends SigarTestCase { } public void testCreate() throws Exception { - Sigar sigar = new Sigar(); + Sigar sigar = getSigar(); ThreadCpu cpu; try {