fix npe when auth cache is not registered

This commit is contained in:
Maxim Muzafarov 2026-07-27 17:19:33 +02:00
parent a7455f1dfc
commit 3272df2f15
No known key found for this signature in database
GPG Key ID: 7FEC714D84388C16
3 changed files with 14 additions and 0 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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()
{