From 1a05fcf52b8162cc0ed7c6dbcf6e0109b50fa582 Mon Sep 17 00:00:00 2001 From: Ekaterina Dimitrova Date: Tue, 4 Jan 2022 15:51:25 -0500 Subject: [PATCH] Deduplicate warnings for deprecated parameters (changed names) patch by Ekaterina Dimitrova; reviewed by Caleb Rackliffe for CASSANDRA-17160 --- CHANGES.txt | 1 + .../config/YamlConfigurationLoader.java | 18 ++++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index c84e6436ba..1d01ffba7b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 4.0.2 + * Deduplicate warnings for deprecated parameters (changed names) (CASSANDRA-17160) * Update ant-junit to version 1.10.12 (CASSANDRA-17218) * Add droppable tombstone metrics to nodetool tablestats (CASSANDRA-16308) * Fix disk failure triggered when enabling FQL on an unclean directory (CASSANDRA-17136) diff --git a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java index 05b18bebb9..a8d4695cb0 100644 --- a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java +++ b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java @@ -219,6 +219,8 @@ public class YamlConfigurationLoader implements ConfigurationLoader private final Set nullProperties = new HashSet<>(); + private final Set deprecationWarnings = new HashSet<>(); + private final Map, Map> replacements; public PropertiesChecker(Map, Map> replacements) @@ -232,7 +234,7 @@ public class YamlConfigurationLoader implements ConfigurationLoader { final Property result; Map typeReplacements = replacements.getOrDefault(type, Collections.emptyMap()); - if(typeReplacements.containsKey(name)) + if (typeReplacements.containsKey(name)) { Replacement replacement = typeReplacements.get(name); final Property newProperty = super.getProperty(type, replacement.newName); @@ -269,17 +271,14 @@ public class YamlConfigurationLoader implements ConfigurationLoader } }; - if(replacement.deprecated) - { - logger.warn("{} parameter has been deprecated. It has a new name; For more information, please refer to NEWS.txt", name); - } + if (replacement.deprecated) + deprecationWarnings.add(replacement.oldName); } else { result = super.getProperty(type, name); } - if (result instanceof MissingProperty) { missingProperties.add(result.getName()); @@ -326,14 +325,13 @@ public class YamlConfigurationLoader implements ConfigurationLoader public void check() throws ConfigurationException { if (!nullProperties.isEmpty()) - { throw new ConfigurationException("Invalid yaml. Those properties " + nullProperties + " are not valid", false); - } if (!missingProperties.isEmpty()) - { throw new ConfigurationException("Invalid yaml. Please remove properties " + missingProperties + " from your cassandra.yaml", false); - } + + if (!deprecationWarnings.isEmpty()) + logger.warn("{} parameters have been deprecated. They have new names; For more information, please refer to NEWS.txt", deprecationWarnings); } }