From aa509c7a83dd26061478afe18e27bc8954dfc29b Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Mon, 14 Jul 2008 00:52:32 +0000 Subject: [PATCH] make invoker SigarPermissionDeniedException aware --- bindings/java/src/org/hyperic/sigar/SigarInvoker.java | 11 +++++++++-- .../java/src/org/hyperic/sigar/SigarProxyCache.java | 3 +++ .../java/src/org/hyperic/sigar/test/TestInvoker.java | 5 ++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/bindings/java/src/org/hyperic/sigar/SigarInvoker.java b/bindings/java/src/org/hyperic/sigar/SigarInvoker.java index 72e288a3..f60a5f75 100644 --- a/bindings/java/src/org/hyperic/sigar/SigarInvoker.java +++ b/bindings/java/src/org/hyperic/sigar/SigarInvoker.java @@ -201,7 +201,9 @@ public class SigarInvoker { } public Object invoke(Object arg, String attr) - throws SigarException, SigarNotImplementedException { + throws SigarException, + SigarNotImplementedException, + SigarPermissionDeniedException { Object[] args = null; @@ -218,7 +220,9 @@ public class SigarInvoker { } public Object invoke(Object[] args, String attr) - throws SigarException, SigarNotImplementedException { + throws SigarException, + SigarNotImplementedException, + SigarPermissionDeniedException { Method typeGetter, attrGetter; Object typeObject; @@ -240,6 +244,9 @@ public class SigarInvoker { if (t instanceof SigarNotImplementedException) { throw (SigarNotImplementedException)t; } + else if (t instanceof SigarPermissionDeniedException) { + throw (SigarPermissionDeniedException)t; + } throw new SigarException(msg); } diff --git a/bindings/java/src/org/hyperic/sigar/SigarProxyCache.java b/bindings/java/src/org/hyperic/sigar/SigarProxyCache.java index 54e5a719..fdefa219 100644 --- a/bindings/java/src/org/hyperic/sigar/SigarProxyCache.java +++ b/bindings/java/src/org/hyperic/sigar/SigarProxyCache.java @@ -216,6 +216,9 @@ public class SigarProxyCache if (t instanceof SigarNotImplementedException) { throw new SigarNotImplementedException(msg); } + else if (t instanceof SigarPermissionDeniedException) { + throw new SigarPermissionDeniedException(msg); + } throw new SigarException(msg); } catch (Exception e) { String msg = diff --git a/bindings/java/src/org/hyperic/sigar/test/TestInvoker.java b/bindings/java/src/org/hyperic/sigar/test/TestInvoker.java index fb69fa7d..51a6e98e 100644 --- a/bindings/java/src/org/hyperic/sigar/test/TestInvoker.java +++ b/bindings/java/src/org/hyperic/sigar/test/TestInvoker.java @@ -21,6 +21,7 @@ package org.hyperic.sigar.test; import org.hyperic.sigar.Sigar; import org.hyperic.sigar.SigarException; import org.hyperic.sigar.SigarNotImplementedException; +import org.hyperic.sigar.SigarPermissionDeniedException; import org.hyperic.sigar.SigarProxy; import org.hyperic.sigar.SigarProxyCache; import org.hyperic.sigar.jmx.SigarInvokerJMX; @@ -90,8 +91,10 @@ public class TestInvoker extends SigarTestCase { assertTrue(true); } catch (SigarNotImplementedException e) { traceln(query[0] + " NotImplemented"); + } catch (SigarPermissionDeniedException e) { + traceln(query[0] + " PermissionDenied"); } catch (SigarException e) { - traceln(query[0] + ":" + query[1] + "=" + e.getMessage()); + traceln(query[0] + ":" + query[1] + "=" + e); assertTrue(false); } }