Throwable f = e.getCause(); if (f instanceof Exception){ throw (Exception) f;
@Test public void testInvokeThrows() throws Exception { try { mbeanServerConnection.invoke(testMBeanName, "throwException", new Object[] {new Exception("exception-message")}, new String[] {Throwable.class.getName()}); fail("Expected exception"); } catch (MBeanException e) { assertTrue(e.getCause() instanceof Exception); assertEquals(e.getCause().getMessage(), "exception-message"); } }
@Test public void testInvokeThrows() throws Exception { try { mbeanServerConnection.invoke(testMBeanName, "throwException", new Object[]{new Exception("exception-message")}, new String[]{Throwable.class.getName()}); fail("Expected exception"); } catch (MBeanException e) { assertTrue(e.getCause() instanceof Exception); assertEquals(e.getCause().getMessage(), "exception-message"); } }
@Test public void testInvokeThrows() throws Exception { try { mbeanServerConnection.invoke(testMBeanName, "throwException", new Object[] {new Exception("exception-message")}, new String[] {Throwable.class.getName()}); fail("Expected exception"); } catch (MBeanException e) { assertTrue(e.getCause() instanceof Exception); assertEquals(e.getCause().getMessage(), "exception-message"); } }
@Test public void testInvokeThrows() throws Exception { try { mbeanServerConnection.invoke(testMBeanName, "throwException", new Object[]{new Exception("exception-message")}, new String[]{Throwable.class.getName()}); fail("Expected exception"); } catch (MBeanException e) { assertTrue(e.getCause() instanceof Exception); assertEquals(e.getCause().getMessage(), "exception-message"); } }
public void setLockTimeout(int seconds) throws AdminException { try { Assert.assertTrue(this.objectName != null); this.mbs.setAttribute(this.objectName, new Attribute("lockTimeout", new Integer(seconds))); } catch (MBeanException ex) { Throwable cause = ex.getCause(); if (cause instanceof AdminException) { throw (AdminException) cause; } else { String s = "While calling setLockTimeout on: "+objectName; throw new InternalGemFireException(s, ex); } } catch (Exception ex) { String s = "While calling setLockTimeout on: "+objectName; throw new InternalGemFireException(s, ex); } }
public void setSearchTimeout(int seconds) throws AdminException { try { Assert.assertTrue(this.objectName != null); this.mbs.setAttribute(this.objectName, new Attribute("searchTimeout", new Integer(seconds))); } catch (MBeanException ex) { Throwable cause = ex.getCause(); if (cause instanceof AdminException) { throw (AdminException) cause; } else { String s = "While calling setSearchTimeout on: "+objectName; throw new InternalGemFireException(s, ex); } } catch (Exception ex) { String s = "While calling setSearchTimeout on: "+objectName; throw new InternalGemFireException(s, ex); } }
public SystemMemberRegion getRegion(String path) throws AdminException { try { ObjectName name = (ObjectName) this.mbs.invoke(this.objectName, "manageRegion", new Object[] { path }, new String[] { String.class.getName() }); return new JMXSystemMemberRegion(this.mbs, name); } catch (MBeanException ex) { Throwable cause = ex.getCause(); if (cause instanceof AdminException) { if (cause.getMessage().indexOf("does not contain") != -1) { return null; } } else if (cause instanceof RegionNotFoundException) { return null; } else if (cause instanceof RegionDestroyedException) { return null; } String s = "While calling manageRegion on: "+objectName; throw new InternalGemFireException(s, ex); } catch (RuntimeException ex) { throw ex; } catch (Exception ex) { String s = "While calling manageRegion on: "+objectName; throw new InternalGemFireException(s, ex); } }
public void setLockLease(int seconds) throws AdminException { try { Assert.assertTrue(this.objectName != null); this.mbs.setAttribute(this.objectName, new Attribute("lockLease", new Integer(seconds))); } catch (MBeanException ex) { Throwable cause = ex.getCause(); if (cause instanceof AdminException) { throw (AdminException) cause; } else { String s = "While calling setLockLease on: "+objectName; throw new InternalGemFireException(s, ex); } } catch (Exception ex) { String s = "While calling setLockLease on: "+objectName; throw new InternalGemFireException(s, ex); } }
/** * Handles an exception thrown when invoking MBean method by * unwrapping it appropriately. * * @return The appropriate exception to be thrown */ private RuntimeException handleException(Exception ex) { if (ex instanceof MBeanException) { MBeanException mbe = (MBeanException) ex; Throwable cause = mbe.getCause(); if (cause instanceof RegionNotFoundException) { return (RegionNotFoundException) cause; } else if (cause instanceof RegionDestroyedException) { return (RegionDestroyedException) cause; } else if (cause instanceof ServiceNotFoundException) { // MBeanServerConnection interface returns ServiceNotFoundException // SystemMemberRegion interface needs to throw RegionNotFoundException return new RegionNotFoundException("MBeanServerConnection.getAttribute() caught " + cause.getMessage()); } } else if (ex instanceof InstanceNotFoundException) { // MBeanServerConnection interface returns InstanceNotFoundException // SystemMemberRegion interface needs to throw RegionNotFoundException return new RegionNotFoundException("MBeanServerConnection.getAttribute() caught " + ex.getMessage()); } String s = "While calling MBeanServerConnection.getAttribute()"; return new InternalGemFireException(s, ex); }
logger.error("Exception in MBean", beanEx.getCause()); throw beanEx;
logger.error("Exception in MBean", beanEx.getCause()); throw beanEx;