CASSANDRA-21525 trunk - Verify extension type before initializing reflectively-loaded classes#4943
Open
smiklosovic wants to merge 5 commits into
Open
CASSANDRA-21525 trunk - Verify extension type before initializing reflectively-loaded classes#4943smiklosovic wants to merge 5 commits into
smiklosovic wants to merge 5 commits into
Conversation
Cassandra resolves pluggable extensions by class name from configuration, schema, and tooling inputs. These names were loaded with an initializing Class.forName(name) and type-checked only afterward, so the named class ran its static initializer before its type was confirmed. After this change such classes will be loaded without initialization, verified against the expected interface or base class, and initialized only through normal use after validation. A shared FBUtilities.classForNameWithoutInitialization helper and typed instanceOrConstruct/construct overloads apply this to the configurable extension points loaded by class name: the guardrail value generator and validator, disk-error handler, Accord agent, TCM extension values, the authentication backends and mutual-TLS validators, seed provider, snitch and its location providers, abstract types, secondary and custom indexes, compaction strategy, compressor, replication strategy (including its metadata serializers), SASI analyzers, key and cache providers, query handler, storage and stream hooks, tracing, the JMX authorization proxy, MBeans, clocks, nodetool Sjk, triggers, the memtable factory contract, the guardrails config provider, the auto-repair token-range splitter, crypto provider, SSL context factory, the sstableloader and stress class options, and diagnostic event classes. ParameterizedClass.newInstance also takes an expected type and loads without initialization. Regression tests confirm that an invalid-type load is rejected without initializing the target class, and that valid implementations still resolve. Hard-coded JDK and internal class probes are left unchanged. patch by Jeremiah Jordan; reviewed by <reviewer> for CASSANDRA-21525
Contributor
Author
|
There are changes missing in CompressorRegistry class (introduced recently with CEP-49), please align |
smiklosovic
commented
Jul 16, 2026
| // access or getInstance(TypeParser) invocation below performs the initialization for valid types. | ||
| @SuppressWarnings("unchecked") | ||
| Class<? extends AbstractType<?>> typeClass = | ||
| (Class<? extends AbstractType<?>>)(Class<?>) FBUtilities.classForNameWithoutInitialization(className, |
Contributor
Author
There was a problem hiding this comment.
two casts?
(Class<? extends AbstractType<?>>)(Class<?>)?
JeremiahDJordan
force-pushed
the
CASSANDRA-21525-trunk-noinit
branch
from
July 16, 2026 13:32
14b66b6 to
e94bc88
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cassandra resolves pluggable extensions by class name from configuration, schema, and tooling inputs. These names were loaded with an initializing Class.forName(name) and type-checked only afterward, so the named class ran its static initializer before its type was confirmed. After this change such classes will be loaded without initialization, verified against the expected interface or base class, and initialized only through normal use after validation.
A shared FBUtilities.classForNameWithoutInitialization helper and typed instanceOrConstruct/construct overloads apply this to the configurable extension points loaded by class name: the guardrail value generator and validator, disk-error handler, Accord agent, TCM extension values, the authentication backends and mutual-TLS validators, seed provider, snitch and its location providers, abstract types, secondary and custom indexes, compaction strategy, compressor, replication strategy (including its metadata serializers), SASI analyzers, key and cache providers, query handler, storage and stream hooks, tracing, the JMX authorization proxy, MBeans, clocks, nodetool Sjk, triggers, the memtable factory contract, the guardrails config provider, the auto-repair token-range splitter, crypto provider, SSL context factory, the sstableloader and stress class options, and diagnostic event classes. ParameterizedClass.newInstance also takes an expected type and loads without initialization.
Regression tests confirm that an invalid-type load is rejected without initializing the target class, and that valid implementations still resolve.
Hard-coded JDK and internal class probes are left unchanged.
patch by Jeremiah Jordan; reviewed by for CASSANDRA-21525
Thanks for sending a pull request! Here are some tips if you're new here:
Commit messages should follow the following format:
The Cassandra Jira