You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/08/14 06:48:07 UTC
[GitHub] [kafka] showuon commented on a diff in pull request #12503: Appending value to LIST config should not generate empty string with …
showuon commented on code in PR #12503:
URL: https://github.com/apache/kafka/pull/12503#discussion_r945237980
##########
core/src/main/scala/kafka/server/ConfigAdminManager.scala:
##########
@@ -496,9 +496,9 @@ object ConfigAdminManager {
if (!listType(alterConfigOp.configEntry.name, configKeys))
throw new InvalidConfigurationException(s"Config value append is not allowed for config key: ${alterConfigOp.configEntry.name}")
val oldValueList = Option(configProps.getProperty(alterConfigOp.configEntry.name))
- .orElse(Option(ConfigDef.convertToString(configKeys(configPropName).defaultValue, ConfigDef.Type.LIST)))
- .getOrElse("")
- .split(",").toList
+ .orElse(Option(ConfigDef.convertToString(configKeys(configPropName).defaultValue, ConfigDef.Type.LIST)).filter(s => s.nonEmpty))
Review Comment:
nit: `filter` can be in next line
##########
core/src/test/scala/integration/kafka/api/PlaintextAdminIntegrationTest.scala:
##########
@@ -2480,6 +2480,27 @@ class PlaintextAdminIntegrationTest extends BaseAdminIntegrationTest {
}
}
+ @ParameterizedTest(name = TestInfoUtils.TestWithParameterizedQuorumName)
+ @ValueSource(strings = Array("zk", "kraft"))
+ def testAppendConfigToEmptyDefaultValue(ignored: String): Unit = {
+ client = Admin.create(createConfig)
+ val topic = "testAppendConfigToEmptyDefaultValue"
+ createTopic(topic)
Review Comment:
Could we also add a test for the case that topic config already contains a `LeaderReplicationThrottledReplicasProp` value, to make sure the result is what we expected? Ex:
```java
val p = new Properties()
p.setProperty(LogConfig.LeaderReplicationThrottledReplicasProp, "1:1")
createTopic(topic, topicConfig = p)
...
assertEquals("1:1, 0:0", config.value())
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org