Stefan Miklosovic created CASSANDRA-20450:
---------------------------------------------
Summary: Fix simulator dtests after CASSANDRA-20368
Key: CASSANDRA-20450
URL: https://issues.apache.org/jira/browse/CASSANDRA-20450
Project: Apache Cassandra
Issue Type: Bug
Reporter: Stefan Miklosovic
Assignee: Stefan Miklosovic
After CASSANDRA-20368 was merged, we are getting this in simulator dtests:
{code:java}
Caused by: java.lang.ClassCastException: class
org.apache.cassandra.auth.AllowAllAuthenticator cannot be cast to class
org.apache.cassandra.auth.IAuthenticator
(org.apache.cassandra.auth.AllowAllAuthenticator is in unnamed module of loader
'app'; org.apache.cassandra.auth.IAuthenticator is in unnamed module of loader
org.apache.cassandra.distributed.shared.InstanceClassLoader @740abb5)
at org.apache.cassandra.auth.AuthConfig.applyAuth(AuthConfig.java:54)
at
org.apache.cassandra.config.DatabaseDescriptor.daemonInitialization(DatabaseDescriptor.java:284)
at
org.apache.cassandra.config.DatabaseDescriptor.daemonInitialization(DatabaseDescriptor.java:269)
at
org.apache.cassandra.distributed.impl.Instance.partialStartup(Instance.java:710)
{code}
The problem is that after that was merged, we started to do this:
{code:java}
private static <T> T authInstantiate(ParameterizedClass authCls, Class<T>
defaultCls) {
if (authCls != null && authCls.class_name != null)
{
String authPackage = AuthConfig.class.getPackage().getName();
return ParameterizedClass.newInstance(authCls, List.of("",
authPackage));
}
return ParameterizedClass.newInstance(new
ParameterizedClass(defaultCls.getName()), List.of());
}{code}
while previously it was this
{code:java}
private static <T> T authInstantiate(ParameterizedClass authCls, Class<T>
defaultCls) {
if (authCls != null && authCls.class_name != null)
{
String authPackage = AuthConfig.class.getPackage().getName();
return ParameterizedClass.newInstance(authCls, List.of("",
authPackage));
}
try
{
return defaultCls.newInstance();
}
catch (InstantiationException | IllegalAccessException e)
{
throw new ConfigurationException("Failed to instantiate " +
defaultCls.getName(), e);
}
} {code}
I am not completely sure what's the problem as "normally" it just works, but
when using this code in connection with simulator, my suspicion is that it is
using a different class loader and then creating an instance via
ParameterizedClass.newInstance just messes it up on all the casts etc.
The easy solution here is to just revert to "what was". The only functional
difference here is that when a user does e.g. this in yaml
{code}
authorizer:
{code}
that means, setting authorizer literally to nothing (null), then what the
current trunk code does (which broke the simulator tests) is that it will take
AllowAllAuthorizer, checks what constructor it has and if it has map
constructor it will prefer that one. If it does not have any map constructor,
it will create an instance using no-arg constructor.
I do not think there is any practical difference here so we might just revert
to "what was".
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]