[ 
https://issues.apache.org/jira/browse/CASSANDRA-21525?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jeremiah Jordan updated CASSANDRA-21525:
----------------------------------------
     Bug Category: Parent values: Correctness(12982)
       Complexity: Normal
      Component/s: Local/Config
    Discovered By: Code Inspection
    Fix Version/s: 4.0.x
                   4.1.x
                   5.0.x
                   6.0.x
         Severity: Normal
         Assignee: Jeremiah Jordan
           Status: Open  (was: Triage Needed)

Updated extension loading to follow this pattern:

1. Load with `Class.forName(name, false, loader)`.
2. Verify the expected interface/base class.
3. Initialize only through normal active use after validation.

This was applied to configurable extension points including auth 
(authenticator, authorizer, role manager, internode authenticator, network 
authorizer, CIDR authorizer), TLS validators, seed providers, 
snitches/node-proximity, failure detectors, guardrails (value 
generator/validator/config provider), crypto/key providers, cache providers, 
stream/storage hooks, tracing, query handlers, diagnostics, auto-repair 
splitters, partitioners, TCM extension values, clocks, and CLI-provided tool 
classes.

The shared helpers live in `FBUtilities` (`classForNameWithoutInitialization`, 
`instanceOrConstruct`/`construct` typed overloads) and 
`ParameterizedClass.newInstance(pc, packages, expectedType)`.

Memtable loading now validates the static factory contract before 
initialization:

- `factory(Map)` must return `Memtable.Factory`
- `FACTORY` must be assignable to `Memtable.Factory`

`ParameterizedClass.newInstance` resolves the class across the search packages 
with a non-initializing load and runs the type check once, after the search, so 
a wrong-type match under an earlier search package does not abort the search 
before a valid class under a later package is found. The legacy 2-arg overload 
(no `expectedType`) also loads without initialization and is documented to 
prefer the typed overload.


> Class Loading Improvements
> --------------------------
>
>                 Key: CASSANDRA-21525
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21525
>             Project: Apache Cassandra
>          Issue Type: Bug
>          Components: Local/Config
>            Reporter: Jeremiah Jordan
>            Assignee: Jeremiah Jordan
>            Priority: Normal
>             Fix For: 4.0.x, 4.1.x, 5.0.x, 6.0.x
>
>
> Cassandra resolves pluggable extensions by class name from configuration, 
> schema, and tooling
> inputs (cassandra.yaml, CQL DDL, JMX, schema/TCM, system properties, CLI 
> tools). These names are
> loaded with an initializing `Class.forName(name)` and only checked against 
> the expected extension
> type afterward. That ordering initializes the named class — running its 
> static initializer and any
> side effects — before confirming it is the right type, so a mistyped or 
> invalid class name is
> initialized before it is rejected. The type should be verified before 
> initialization, so that only
> validated extension classes are initialized.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to