jwahoonkim created CASSANDRA-21348:
--------------------------------------
Summary: system_views.settings fails for map settings with
non-string keys
Key: CASSANDRA-21348
URL: https://issues.apache.org/jira/browse/CASSANDRA-21348
Project: Apache Cassandra
Issue Type: Bug
Components: Feature/Virtual Tables
Reporter: jwahoonkim
system_views.settings can fail when rendering map-typed settings whose keys are
not String.
One reproducible case is startup_checks. In Cassandra 5.0.7, configuring
check_data_resurrection under startup_checks allows Cassandra itself to start,
but querying system_views.settings fails with ClassCastException.
Reproduction
============
Add the following to cassandra.yaml:
startup_checks:
check_data_resurrection:
enabled: true
Start Cassandra and run:
SELECT * FROM system_views.settings;
SELECT * FROM system_views.settings WHERE name = 'startup_checks';
Actual result
=============
The query fails with:
java.lang.ClassCastException:
org.apache.cassandra.service.StartupChecks$StartupCheckType cannot be cast to
java.lang.String
Expected result
===============
system_views.settings should render the startup_checks value and should not
fail.
For example:
startup_checks = \{check_data_resurrection={enabled=true}}
Cause
=====
Config.startup_checks is declared as:
Map<StartupChecks.StartupCheckType, Map<String, Object>>
However, SettingsTable.getValue() currently handles map settings by casting the
value to:
Map<String, Object>
and iterating entries as:
Map.Entry<String, Object>
This assumes all map keys are String, which is not true for startup_checks.
Proposed fix
============
Handle map settings generically as Map<?, ?> and render keys using:
String.valueOf(entry.getKey())
while preserving existing password redaction logic.
This is intentionally not a startup_checks-specific special case.
Test
====
A unit test is added in SettingsTableTest to verify:
- startup_checks is rendered correctly
- SELECT * FROM settings does not throw
Verification
============
ant testsome -Dtest.name=org.apache.cassandra.db.virtual.SettingsTableTest
-Dtest.methods=testStartupChecksWithEnumKeys
Result:
Tests run: 1, Failures: 0, Errors: 0
BUILD SUCCESSFUL
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]