mirror of https://github.com/apache/kafka.git
MINOR: leverage preProcessParsedConfig within AbstractConfig (#19259)
In past, we have `AbstractConfig#preProcessParsedConfig` but did not use its return value Reviewers: Ken Huang <s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
fef9aebb19
commit
a524fc64b4
|
@ -109,8 +109,7 @@ public class AbstractConfig {
|
|||
*/
|
||||
@SuppressWarnings({"this-escape"})
|
||||
public AbstractConfig(ConfigDef definition, Map<?, ?> originals, Map<String, ?> configProviderProps, boolean doLog) {
|
||||
Map<String, Object> originalMap = Utils.castToStringObjectMap(originals);
|
||||
preProcessParsedConfig(originalMap);
|
||||
Map<String, Object> originalMap = preProcessParsedConfig(Collections.unmodifiableMap(Utils.castToStringObjectMap(originals)));
|
||||
this.originals = resolveConfigVariables(configProviderProps, originalMap);
|
||||
this.values = definition.parse(this.originals);
|
||||
Map<String, Object> configUpdates = postProcessParsedConfig(Collections.unmodifiableMap(this.values));
|
||||
|
@ -144,7 +143,6 @@ public class AbstractConfig {
|
|||
*/
|
||||
public AbstractConfig(ConfigDef definition, Map<?, ?> originals, boolean doLog) {
|
||||
this(definition, originals, Collections.emptyMap(), doLog);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,7 +153,7 @@ public class AbstractConfig {
|
|||
* @return a map of updates that should be applied to the configuration (will be validated to prevent bad updates)
|
||||
*/
|
||||
protected Map<String, Object> preProcessParsedConfig(Map<String, Object> parsedValues) {
|
||||
return Map.of();
|
||||
return parsedValues;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -114,6 +114,13 @@ public class AbstractConfigTest {
|
|||
assertEquals(expected, originalsWithPrefix);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreprocessConfig() {
|
||||
Properties props = new Properties();
|
||||
TestConfig config = new TestConfig(props);
|
||||
assertEquals("success", config.get("preprocess"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValuesWithPrefixOverride() {
|
||||
String prefix = "prefix.";
|
||||
|
@ -702,17 +709,32 @@ public class AbstractConfigTest {
|
|||
|
||||
public static final String METRIC_REPORTER_CLASSES_CONFIG = "metric.reporters";
|
||||
private static final String METRIC_REPORTER_CLASSES_DOC = "A list of classes to use as metrics reporters.";
|
||||
public static final String PREPROCESSOR_CONFIG = "preprocess";
|
||||
private static final String PREPROCESSOR_CONFIG_DOC = "Override from preprocess step.";
|
||||
|
||||
static {
|
||||
CONFIG = new ConfigDef().define(METRIC_REPORTER_CLASSES_CONFIG,
|
||||
Type.LIST,
|
||||
"",
|
||||
Importance.LOW,
|
||||
METRIC_REPORTER_CLASSES_DOC);
|
||||
METRIC_REPORTER_CLASSES_DOC)
|
||||
.define(PREPROCESSOR_CONFIG,
|
||||
Type.STRING,
|
||||
"",
|
||||
Importance.LOW,
|
||||
PREPROCESSOR_CONFIG_DOC);
|
||||
}
|
||||
|
||||
public TestConfig(Map<?, ?> props) {
|
||||
super(CONFIG, props);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> preProcessParsedConfig(Map<String, Object> parsedValues) {
|
||||
Map<String, Object> ret = new HashMap<>(parsedValues);
|
||||
ret.put("preprocess", "success");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ConfiguredFakeMetricsReporter extends FakeMetricsReporter {
|
||||
|
|
Loading…
Reference in New Issue