chia7712 commented on a change in pull request #9682:
URL: https://github.com/apache/kafka/pull/9682#discussion_r535428840



##########
File path: core/src/test/scala/unit/kafka/server/DynamicBrokerConfigTest.scala
##########
@@ -400,6 +400,33 @@ class DynamicBrokerConfigTest {
     newprops.put(KafkaConfig.BackgroundThreadsProp, "100")
     dynamicBrokerConfig.updateBrokerConfig(0, newprops)
   }
+
+  @Test
+  def testImproperConfigsAreRemoved(): Unit = {
+    val props = TestUtils.createBrokerConfig(0, TestUtils.MockZkConnect)
+    val configs = KafkaConfig(props)
+
+    assertEquals(Int.MaxValue, configs.maxConnections)
+    assertEquals(1048588, configs.messageMaxBytes)
+
+    var newProps = new Properties()
+    newProps.put(KafkaConfig.MaxConnectionsProp, "9999")
+    newProps.put(KafkaConfig.MessageMaxBytesProp, "2222")
+
+    configs.dynamicConfig.updateDefaultConfig(newProps)
+    assertEquals(9999, configs.maxConnections)
+    assertEquals(2222, configs.messageMaxBytes)
+
+    newProps = new Properties()
+    newProps.put(KafkaConfig.MaxConnectionsProp, "INVALID_INT")
+    newProps.put(KafkaConfig.MessageMaxBytesProp, "1111")
+
+    configs.dynamicConfig.updateDefaultConfig(newProps)
+    // Invalid value should be skipped and reassigned as Originals
+    assertEquals(Int.MaxValue, configs.maxConnections)

Review comment:
       Could you replace ```Int.MaxValue``` by ```Defaults.MaxConnections```? 

##########
File path: core/src/main/scala/kafka/server/DynamicBrokerConfig.scala
##########
@@ -467,7 +467,9 @@ class DynamicBrokerConfig(private val kafkaConfig: 
KafkaConfig) extends Logging
             case _: Exception => true
           }
         }
-        invalidProps.foreach(props.remove)
+        invalidProps.foreach {

Review comment:
       How about ```invalidProps.keys.foreach(props.remove)```? it is still one 
line.

##########
File path: core/src/test/scala/unit/kafka/server/DynamicBrokerConfigTest.scala
##########
@@ -400,6 +400,33 @@ class DynamicBrokerConfigTest {
     newprops.put(KafkaConfig.BackgroundThreadsProp, "100")
     dynamicBrokerConfig.updateBrokerConfig(0, newprops)
   }
+
+  @Test
+  def testImproperConfigsAreRemoved(): Unit = {
+    val props = TestUtils.createBrokerConfig(0, TestUtils.MockZkConnect)
+    val configs = KafkaConfig(props)
+
+    assertEquals(Int.MaxValue, configs.maxConnections)
+    assertEquals(1048588, configs.messageMaxBytes)
+
+    var newProps = new Properties()
+    newProps.put(KafkaConfig.MaxConnectionsProp, "9999")
+    newProps.put(KafkaConfig.MessageMaxBytesProp, "2222")
+
+    configs.dynamicConfig.updateDefaultConfig(newProps)
+    assertEquals(9999, configs.maxConnections)
+    assertEquals(2222, configs.messageMaxBytes)
+
+    newProps = new Properties()
+    newProps.put(KafkaConfig.MaxConnectionsProp, "INVALID_INT")
+    newProps.put(KafkaConfig.MessageMaxBytesProp, "1111")
+
+    configs.dynamicConfig.updateDefaultConfig(newProps)
+    // Invalid value should be skipped and reassigned as Originals

Review comment:
       "Originals" -> "default 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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to