mirror of https://github.com/apache/cassandra
Verify the audit logger class without initializing it during the existence check
isAuditLoggerClassExists loaded the configured audit logger class through the initializing helper only to test for its presence. Load it without initialization and verify it is an IAuditLogger instead.
This commit is contained in:
parent
ea302e2294
commit
2a38e03070
|
|
@ -695,7 +695,7 @@ public class FBUtilities
|
|||
|
||||
try
|
||||
{
|
||||
FBUtilities.classForName(className, "Audit logger");
|
||||
FBUtilities.classForNameWithoutInitialization(className, "Audit logger", IAuditLogger.class);
|
||||
}
|
||||
catch (ConfigurationException e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ import org.apache.cassandra.exceptions.ConfigurationException;
|
|||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class FBUtilitiesTest
|
||||
|
|
@ -101,6 +102,17 @@ public class FBUtilitiesTest
|
|||
assertFalse(ClassLoadingTestSupport.wasInitialized(ClassLoadingTestNonAssignable.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsAuditLoggerClassExistsRejectsWrongTypeWithoutInitializing()
|
||||
{
|
||||
ClassLoadingTestSupport.assertNotInitialized(ClassLoadingTestNonAssignable.class);
|
||||
assertFalse(FBUtilities.isAuditLoggerClassExists(ClassLoadingTestNonAssignable.class.getName()));
|
||||
assertFalse(ClassLoadingTestSupport.wasInitialized(ClassLoadingTestNonAssignable.class));
|
||||
|
||||
assertTrue(FBUtilities.isAuditLoggerClassExists("NoOpAuditLogger"));
|
||||
assertFalse(FBUtilities.isAuditLoggerClassExists("does.not.ExistAuditLogger"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareByteSubArrays()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue