You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Brandon Williams (Jira)" <ji...@apache.org> on 2023/04/28 11:01:00 UTC
[jira] [Updated] (CASSANDRA-18486) LeveledCompactionStrategy does not check its constructor
[ https://issues.apache.org/jira/browse/CASSANDRA-18486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Brandon Williams updated CASSANDRA-18486:
-----------------------------------------
Bug Category: Parent values: Correctness(12982)
Complexity: Low Hanging Fruit
Component/s: Local/Compaction/LCS
Discovered By: User Report
Fix Version/s: 5.x
Severity: Low
Status: Open (was: Triage Needed)
> LeveledCompactionStrategy does not check its constructor
> --------------------------------------------------------
>
> Key: CASSANDRA-18486
> URL: https://issues.apache.org/jira/browse/CASSANDRA-18486
> Project: Cassandra
> Issue Type: Bug
> Components: Local/Compaction/LCS
> Reporter: Hao Zhong
> Priority: Normal
> Fix For: 5.x
>
>
> LeveledCompactionStrategy has the following code:
>
> {code:java}
> public static Map<String, String> validateOptions(Map<String, String> options) throws ConfigurationException
> {
> Map<String, String> uncheckedOptions = AbstractCompactionStrategy.validateOptions(options);
> String size = options.containsKey(SSTABLE_SIZE_OPTION) ? options.get(SSTABLE_SIZE_OPTION) : "1";
> try
> {
> int ssSize = Integer.parseInt(size);
> if (ssSize < 1)
> {
> throw new ConfigurationException(String.format("%s must be larger than 0, but was %s", SSTABLE_SIZE_OPTION, ssSize));
> }
> }
> catch (NumberFormatException ex)
> {
> throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", size, SSTABLE_SIZE_OPTION), ex);
> }
> ...
> } {code}
> This method throws ConfigurationException when the configuration file is wrong. The thrown exception is easy to understand, and calling code can catch this exception to handle configuration files with wrong formats. However, the constructor of this class does not check configuration files:
>
>
>
> {code:java}
> public LeveledCompactionStrategy(ColumnFamilyStore cfs, Map<String, String> options)
> { ...
>
> configuredMaxSSTableSize = Integer.parseInt(options.get(SSTABLE_SIZE_OPTION));
> ...
> configuredLevelFanoutSize = Integer.parseInt(options.get(LEVEL_FANOUT_SIZE_OPTION));
> ...
> }
> {code}
> As a result, this class can throw NumberFormatException when configuration files are wrong, and will not throw ConfigurationException.
> It is strange for calling code to call the static validation method before calling its constructor. Can this problem be fixed?
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org