Hao Zhong created CASSANDRA-18486:
-------------------------------------
Summary: LeveledCompactionStrategy does not check its constructor
Key: CASSANDRA-18486
URL: https://issues.apache.org/jira/browse/CASSANDRA-18486
Project: Cassandra
Issue Type: Bug
Reporter: Hao Zhong
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: [email protected]
For additional commands, e-mail: [email protected]