kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rha...@apache.org
Subject [kafka] branch 2.0 updated: KAFKA-8363: Fix parsing bug for config providers (#6726)
Date Tue, 14 May 2019 20:02:05 GMT
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 <chrise@confluent.io>
AuthorDate: Tue May 14 12:32:54 2019 -0700

    KAFKA-8363: Fix parsing bug for config providers (#6726)
    
    Author: Chris Egerton <cegerton@oberlin.edu>
    Reviewers: Robert Yokota <rayokota@gmail.com>, Randall Hauch <rhauch@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();


Mime
View raw message