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

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


The following commit(s) were added to refs/heads/2.0 by this push:
     new 765ebf6  KAFKA-8363: Fix parsing bug for config providers (#6726)
765ebf6 is described below

commit 765ebf675f3add8dd628e53a42e16bb084994776
Author: Chris Egerton <chr...@confluent.io>
AuthorDate: Tue May 14 12:32:54 2019 -0700

    KAFKA-8363: Fix parsing bug for config providers (#6726)
    
    Author: Chris Egerton <ceger...@oberlin.edu>
    Reviewers: Robert Yokota <rayok...@gmail.com>, Randall Hauch 
<rha...@gmail.com>
---
 .../java/org/apache/kafka/common/config/ConfigTransformer.java     | 2 +-
 .../java/org/apache/kafka/common/config/ConfigTransformerTest.java | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java 
b/clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java
index 6430ffd..c126472 100644
--- 
a/clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java
+++ 
b/clients/src/main/java/org/apache/kafka/common/config/ConfigTransformer.java
@@ -53,7 +53,7 @@ import java.util.regex.Pattern;
  * {@link ConfigProvider#unsubscribe(String, Set, ConfigChangeCallback)} 
methods.
  */
 public class ConfigTransformer {
-    public static final Pattern DEFAULT_PATTERN = 
Pattern.compile("\\$\\{(.*?):((.*?):)?(.*?)\\}");
+    public static final Pattern DEFAULT_PATTERN = 
Pattern.compile("\\$\\{([^}]*?):(([^}]*?):)?([^}]*?)\\}");
     private static final String EMPTY_PATH = "";
 
     private final Map<String, ConfigProvider> configProviders;
diff --git 
a/clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java
 
b/clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java
index e2b9f6b..12c6b1f 100644
--- 
a/clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java
+++ 
b/clients/src/test/java/org/apache/kafka/common/config/ConfigTransformerTest.java
@@ -96,6 +96,13 @@ public class ConfigTransformerTest {
     }
 
     @Test
+    public void testReplaceMultipleVariablesWithoutPathInValue() throws 
Exception {
+        ConfigTransformerResult result = 
configTransformer.transform(Collections.singletonMap(MY_KEY, "first 
${test:testKey}; second ${test:testKey}"));
+        Map<String, String> data = result.data();
+        assertEquals("first testResultNoPath; second testResultNoPath", 
data.get(MY_KEY));
+    }
+
+    @Test
     public void testNullConfigValue() throws Exception {
         ConfigTransformerResult result = 
configTransformer.transform(Collections.singletonMap(MY_KEY, null));
         Map<String, String> data = result.data();

Reply via email to