[ https://issues.apache.org/jira/browse/CASSANDRA-18486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17717751#comment-17717751 ]
Caleb Rackliffe commented on CASSANDRA-18486: --------------------------------------------- {{validateOptions()}} is called in {{CompactionParams#validate()}} via reflection, and I think the reason for this is that compaction strategies are defined in DDL/on a table-by-table basis. Do you have a specific proposal in mind? > 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-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org