Skip to content

Commit 1c718ab

Browse files
JwahoonKimsmiklosovic
authored andcommitted
Fix failing select on system_views.settings for non-string keys
patch by JwahoonKim; reviewed by Jyothsna Konisa, Dmitry Konstantinov, Stefan Miklosovic for CASSANDRA-21348
1 parent 8093c3c commit 1c718ab

3 files changed

Lines changed: 18 additions & 4 deletions

File tree

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
5.0.9
2+
* Fix failing select on system_views.settings for non-string keys (CASSANDRA-21348)
23
* Ensure SAI sends range tombstones to the coordinator for queries on static columns (CASSANDRA-21332)
34
Merged from 4.1:
45
* Add Paxos v2 option and informatin in cassandra.yaml (CASSANDRA-21316)

src/java/org/apache/cassandra/db/virtual/SettingsTable.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,16 @@ else if (value instanceof Collection)
111111
else if (value instanceof Map)
112112
{
113113
Map<String, Object> map = new HashMap<>();
114-
for (Map.Entry<String, Object> entry : ((Map<String, Object>) value).entrySet())
114+
for (Map.Entry<?, ?> entry : ((Map<?, ?>) value).entrySet())
115115
{
116+
String key = String.valueOf(entry.getKey());
116117
// this is done on best-effort basis as we do not have names in parameters
117118
// inherently under control as this is what a user is responsible for
118119
// when dealing with custom implementations
119-
if (entry.getKey().endsWith("_password") || entry.getKey().equals("password"))
120-
map.put(entry.getKey(), Redacted.REDACTED_STRING);
120+
if (key.endsWith("_password") || key.equals("password"))
121+
map.put(key, Redacted.REDACTED_STRING);
121122
else
122-
map.put(entry.getKey(), entry.getValue());
123+
map.put(key, entry.getValue());
123124
}
124125

125126
return tryConstructJson(map);

test/unit/org/apache/cassandra/db/virtual/SettingsTableTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import org.apache.cassandra.cql3.CQLTester;
4646
import org.apache.cassandra.distributed.shared.WithProperties;
4747
import org.apache.cassandra.security.SSLFactory;
48+
import org.apache.cassandra.service.StartupChecks.StartupCheckType;
4849
import org.slf4j.Logger;
4950
import org.slf4j.LoggerFactory;
5051
import org.yaml.snakeyaml.introspector.Property;
@@ -135,6 +136,17 @@ public void testSelectEmpty() throws Throwable
135136
assertRowsNet(executeNet(q));
136137
}
137138

139+
@Test
140+
public void testStartupChecksWithEnumKeys() throws Throwable
141+
{
142+
Map<String, Object> checkDataResurrection = new LinkedHashMap<>();
143+
checkDataResurrection.put("enabled", true);
144+
config.startup_checks.put(StartupCheckType.check_data_resurrection, checkDataResurrection);
145+
146+
check("startup_checks", "{check_data_resurrection={enabled=true}}");
147+
Assert.assertFalse(executeNet("SELECT * FROM vts.settings").all().isEmpty());
148+
}
149+
138150
@Test
139151
public void testSelectOverride() throws Throwable
140152
{

0 commit comments

Comments
 (0)