mirror of https://github.com/apache/cassandra
fix npe when auth cache is not registered
This commit is contained in:
parent
a7455f1dfc
commit
3272df2f15
|
|
@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory;
|
|||
import org.apache.cassandra.audit.AuditLogManager;
|
||||
import org.apache.cassandra.auth.AuthCache;
|
||||
import org.apache.cassandra.auth.AuthCacheMBean;
|
||||
import org.apache.cassandra.auth.AuthCacheService;
|
||||
import org.apache.cassandra.auth.AuthenticatedUser;
|
||||
import org.apache.cassandra.auth.JMXResource;
|
||||
import org.apache.cassandra.auth.Permission;
|
||||
|
|
@ -596,6 +597,8 @@ public class AuthorizationProxy implements InvocationHandler
|
|||
() -> true);
|
||||
|
||||
MBeanWrapper.instance.registerMBean(this, MBEAN_NAME_BASE + DEPRECATED_CACHE_NAME);
|
||||
// Registration makes this cache discovearble by the management transport MBean accessor
|
||||
AuthCacheService.instance.register(this);
|
||||
}
|
||||
|
||||
public void invalidatePermissions(String roleName)
|
||||
|
|
|
|||
|
|
@ -2535,6 +2535,9 @@ public class NodeProbe implements AutoCloseable
|
|||
}
|
||||
}
|
||||
|
||||
if (delegate == null)
|
||||
throw new RuntimeException(new InstanceNotFoundException(mbeanClass.getSimpleName() + " is not available on this node"));
|
||||
|
||||
try
|
||||
{
|
||||
return method.invoke(delegate, args);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.cassandra.management;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.cassandra.auth.jmx.AuthorizationProxy;
|
||||
import org.apache.cassandra.cql3.CQLTester;
|
||||
import org.apache.cassandra.db.ColumnFamilyStoreMBean;
|
||||
|
||||
|
|
@ -69,6 +70,13 @@ public class InternalNodeMBeanAccessorTest extends CQLTester
|
|||
.noneSatisfy(e -> assertThat(e.getValue().getTableName()).isEqualTo(indexStoreName));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindMBeanResolvesJmxPermissionsCache()
|
||||
{
|
||||
AuthorizationProxy.JmxPermissionsCache expected = AuthorizationProxy.jmxPermissionsCache;
|
||||
assertThat(accessor.findMBean(AuthorizationProxy.JmxPermissionsCacheMBean.class)).isSameAs(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFindCompressionDictionaryContract()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue