From 580ba7a04aaf691f2e951a70560d163d6cb463a8 Mon Sep 17 00:00:00 2001 From: Gianluca Finocchiaro Date: Tue, 17 Dec 2024 10:29:13 +0100 Subject: [PATCH] Fix evaluation of template expressions (#32) --- .../lightstreamer/kafka/common/expressions/Expressions.java | 2 +- .../kafka/common/expressions/ExpressionsTest.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kafka-connector-project/kafka-connector/src/main/java/com/lightstreamer/kafka/common/expressions/Expressions.java b/kafka-connector-project/kafka-connector/src/main/java/com/lightstreamer/kafka/common/expressions/Expressions.java index 84975fb1..4953cdbf 100644 --- a/kafka-connector-project/kafka-connector/src/main/java/com/lightstreamer/kafka/common/expressions/Expressions.java +++ b/kafka-connector-project/kafka-connector/src/main/java/com/lightstreamer/kafka/common/expressions/Expressions.java @@ -94,7 +94,7 @@ public boolean equals(Object obj) { private static Pattern TEMPLATE_GLOBAL = Pattern.compile("(^[a-zA-Z0-9_-]+)(-" + SELECTION_REGEX + ")$"); private static Pattern TEMPLATE_LOCAL = - Pattern.compile("(([a-zA-Z\\._]\\w*)=([a-zA-Z0-9\\.\\[\\]\\*]+)),?"); + Pattern.compile("(([a-zA-Z\\._]\\w*)=([a-zA-Z0-9_\\.\\[\\]\\*]+)),?"); private static Pattern SUBSCRIBED_GLOBAL = Pattern.compile("([a-zA-Z0-9_-]+)(-\\[(.*)\\])?"); private static Pattern SUBSCRIBED_LOCAL = Pattern.compile("(([a-zA-Z\\._]\\w*)=([^,]+)),?"); private static Pattern FIELD = Pattern.compile(SELECTION_REGEX); diff --git a/kafka-connector-project/kafka-connector/src/test/java/com/lightstreamer/kafka/common/expressions/ExpressionsTest.java b/kafka-connector-project/kafka-connector/src/test/java/com/lightstreamer/kafka/common/expressions/ExpressionsTest.java index d065db47..b5b8f1bd 100644 --- a/kafka-connector-project/kafka-connector/src/test/java/com/lightstreamer/kafka/common/expressions/ExpressionsTest.java +++ b/kafka-connector-project/kafka-connector/src/test/java/com/lightstreamer/kafka/common/expressions/ExpressionsTest.java @@ -115,7 +115,11 @@ static Stream templateArgs() { arguments( "template-#{param1=OFFSET,param2=PARTITION,param3=TIMESTAMP}", "template", - Map.of("param1", "OFFSET", "param2", "PARTITION", "param3", "TIMESTAMP"))); + Map.of("param1", "OFFSET", "param2", "PARTITION", "param3", "TIMESTAMP")), + arguments( + "template-#{param1=VALUE.complex_attrib_name.child_1_}", + "template", + Map.of("param1", "VALUE.complex_attrib_name.child_1_"))); } @ParameterizedTest