diff --git a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java index 07ce94e4..0fb5271a 100644 --- a/bindings/java/src/org/hyperic/sigar/cmd/Mx.java +++ b/bindings/java/src/org/hyperic/sigar/cmd/Mx.java @@ -71,7 +71,7 @@ public class Mx extends SigarCommandBase { SigarRegistry registry = new SigarRegistry(this.proxy); try { server.registerMBean(registry, null); - SigarProcess proc = new SigarProcess(); + SigarProcess proc = new SigarProcess(this.sigar); server.registerMBean(proc, new ObjectName(proc.getObjectName())); isRegistered = true; } catch (Exception e) { diff --git a/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java b/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java index 2690566d..1af9a22e 100644 --- a/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java +++ b/bindings/java/src/org/hyperic/sigar/jmx/SigarProcess.java @@ -40,16 +40,18 @@ public class SigarProcess implements SigarProcessMBean { private long pid = -1; public SigarProcess() { - this(new Sigar()); - } - - public SigarProcess(Sigar sigar) { - this.sigarImpl = sigar; + this.sigarImpl = new Sigar(); this.sigar = SigarProxyCache.newInstance(sigarImpl); } + public SigarProcess(SigarProxy sigar) { + this.sigar = sigar; + } + public void close() { - this.sigarImpl.close(); + if (this.sigarImpl != null) { + this.sigarImpl.close(); + } } private RuntimeException unexpectedError(String type,