This is an automated email from the ASF dual-hosted git repository.

mimaison pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 9de16bd  KAFKA-10460: ReplicaListValidator format checking is 
incomplete (#9326)
9de16bd is described below

commit 9de16bd2e64431b1b25d7a34aae78c6c98795143
Author: Ankit Kumar <[email protected]>
AuthorDate: Thu Dec 3 15:36:48 2020 +0100

    KAFKA-10460: ReplicaListValidator format checking is incomplete (#9326)
    
    
    Co-authored-by: akumar <[email protected]>
    Reviewers: Mickael Maison <[email protected]>, Viktor Somogyi-Vass 
<[email protected]>
---
 core/src/main/scala/kafka/server/ConfigHandler.scala   | 2 +-
 core/src/test/scala/unit/kafka/log/LogConfigTest.scala | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/core/src/main/scala/kafka/server/ConfigHandler.scala 
b/core/src/main/scala/kafka/server/ConfigHandler.scala
index cb18c9f..c998ac2 100644
--- a/core/src/main/scala/kafka/server/ConfigHandler.scala
+++ b/core/src/main/scala/kafka/server/ConfigHandler.scala
@@ -238,7 +238,7 @@ object ThrottledReplicaListValidator extends Validator {
   override def ensureValid(name: String, value: Any): Unit = {
     def check(proposed: Seq[Any]): Unit = {
       if (!(proposed.forall(_.toString.trim.matches("([0-9]+:[0-9]+)?"))
-        || proposed.headOption.exists(_.toString.trim.equals("*"))))
+        || proposed.mkString.trim.equals("*")))
         throw new ConfigException(name, value,
           s"$name must be the literal '*' or a list of replicas in the 
following format: [partitionId]:[brokerId],[partitionId]:[brokerId],...")
     }
diff --git a/core/src/test/scala/unit/kafka/log/LogConfigTest.scala 
b/core/src/test/scala/unit/kafka/log/LogConfigTest.scala
index 09f4503..c3d8c2d 100644
--- a/core/src/test/scala/unit/kafka/log/LogConfigTest.scala
+++ b/core/src/test/scala/unit/kafka/log/LogConfigTest.scala
@@ -113,6 +113,8 @@ class LogConfigTest {
     assertFalse(isValid("100 :0,10:   "))
     assertFalse(isValid("100: 0,10:   "))
     assertFalse(isValid("100:0,10 :   "))
+    assertFalse(isValid("*,100:10"))
+    assertFalse(isValid("* ,100:10"))
   }
 
   /* Sanity check that toHtmlTable produces one of the expected configs */

Reply via email to