JBoss Cache SVN: r8511 - in core/trunk/src: test/java/org/jboss/cache/jmx and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: tkimura
Date: 2012-07-17 00:39:41 -0400 (Tue, 17 Jul 2012)
New Revision: 8511
Modified:
core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java
core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java
Log:
[JBCACHE-1604] Fix NullPointerException in ResourceDMBean.invoke()
Modified: core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2012-07-17 04:38:19 UTC (rev 8510)
+++ core/trunk/src/main/java/org/jboss/cache/jmx/ResourceDMBean.java 2012-07-17 04:39:41 UTC (rev 8511)
@@ -254,10 +254,14 @@
{
log.trace("Invoke method called on " + name);
}
- Class<?>[] classes = new Class[sig.length];
- for (int i = 0; i < classes.length; i++)
+ Class<?>[] classes = null;
+ if (sig != null)
{
- classes[i] = getClassForName(sig[i]);
+ classes = new Class[sig.length];
+ for (int i = 0; i < classes.length; i++)
+ {
+ classes[i] = getClassForName(sig[i]);
+ }
}
Method method = getObject().getClass().getMethod(name, classes);
return method.invoke(getObject(), args);
Modified: core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java 2012-07-17 04:38:19 UTC (rev 8510)
+++ core/trunk/src/test/java/org/jboss/cache/jmx/ResourceDMBeanTest.java 2012-07-17 04:39:41 UTC (rev 8511)
@@ -36,6 +36,18 @@
{
/**
+ * Invoke with sig=null
+ * https://issues.jboss.org/browse/JBCACHE-1604
+ */
+ public void testInvokeWithNullSig() throws Exception
+ {
+ Aaa aaa = new Aaa();
+ ResourceDMBean resourceDMBean = new ResourceDMBean(aaa);
+ resourceDMBean.invoke("baseMethod", new Object[0], null);
+ assert aaa.invoked;
+ }
+
+ /**
* If we have a method in the base class that is annotated as @ManagedOperation, will this be seen the same
* way in the inherited class?
*/
@@ -48,8 +60,11 @@
static class Aaa
{
+ boolean invoked = false;
@ManagedOperation
- public void baseMethod() {}
+ public void baseMethod() {
+ invoked = true;
+ }
}
static class Bbb extends Aaa