From b3603f44891f88127995d4e6ae39d064b8473378 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 29 Apr 2009 14:34:40 -0700 Subject: [PATCH] SigarProcess.close only applies to SigarProcess(void) constructor --- bindings/java/src/org/hyperic/sigar/cmd/Mx.java | 2 +- .../src/org/hyperic/sigar/jmx/SigarProcess.java | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) 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,