Skip to content

Commit

Permalink
Deduplicate warnings for deprecated parameters (changed names)
Browse files Browse the repository at this point in the history
patch by Ekaterina Dimitrova; reviewed by Caleb Rackliffe for CASSANDRA-17160
  • Loading branch information
ekaterinadimitrova2 committed Jan 8, 2022
1 parent 57a7b8a commit 1a05fcf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions 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)
Expand Down
18 changes: 8 additions & 10 deletions src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
Expand Up @@ -219,6 +219,8 @@ private static class PropertiesChecker extends PropertyUtils

private final Set<String> nullProperties = new HashSet<>();

private final Set<String> deprecationWarnings = new HashSet<>();

private final Map<Class<?>, Map<String, Replacement>> replacements;

public PropertiesChecker(Map<Class<?>, Map<String, Replacement>> replacements)
Expand All @@ -232,7 +234,7 @@ public Property getProperty(Class<? extends Object> type, String name)
{
final Property result;
Map<String, Replacement> 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);
Expand Down Expand Up @@ -269,17 +271,14 @@ public <A extends Annotation> A getAnnotation(Class<A> aClass)
}
};

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());
Expand Down Expand Up @@ -326,14 +325,13 @@ public <A extends Annotation> A getAnnotation(Class<A> aClass)
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);
}
}

Expand Down

0 comments on commit 1a05fcf

Please sign in to comment.