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

bamaer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 9d48cb3cec harden the filter value, fixes #8596 (#8598)
9d48cb3cec is described below

commit 9d48cb3ceccb0d49a6510aa70d7e1afecd13df2a
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Fri Sep 25 15:30:05 2026 +0200

    harden the filter value, fixes #8596 (#8598)
---
 .../main/java/org/apache/hop/core/Condition.java   |  4 ++--
 .../java/org/apache/hop/core/ConditionTest.java    | 28 ++++++++++++++++++++++
 .../apache/hop/ui/core/widget/ConditionEditor.java |  7 +++---
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/core/src/main/java/org/apache/hop/core/Condition.java 
b/core/src/main/java/org/apache/hop/core/Condition.java
index 3ac1437544..0c743ff545 100644
--- a/core/src/main/java/org/apache/hop/core/Condition.java
+++ b/core/src/main/java/org/apache/hop/core/Condition.java
@@ -685,7 +685,7 @@ public class Condition implements Cloneable {
       } else {
         retval.append(leftValueName + " " + getFunctionDesc());
         if (function != NULL && function != NOT_NULL) {
-          if (rightValueName != null) {
+          if (StringUtils.isNotEmpty(rightValueName)) {
             retval.append(" ");
             retval.append(rightValueName);
           } else {
@@ -772,7 +772,7 @@ public class Condition implements Cloneable {
       if (getLeftValueName() != null) {
         fields.put(getLeftValueName(), "-");
       }
-      if (getRightValueName() != null) {
+      if (StringUtils.isNotEmpty(getRightValueName())) {
         fields.put(getRightValueName(), "-");
       }
     } else {
diff --git a/core/src/test/java/org/apache/hop/core/ConditionTest.java 
b/core/src/test/java/org/apache/hop/core/ConditionTest.java
index d1bd19ddb5..fe9f8b480c 100644
--- a/core/src/test/java/org/apache/hop/core/ConditionTest.java
+++ b/core/src/test/java/org/apache/hop/core/ConditionTest.java
@@ -138,6 +138,34 @@ class ConditionTest {
     assertEquals(Function.LARGER_EQUAL, condition.getFunction());
   }
 
+  /**
+   * Issue #8596: an empty {@code <rightvalue/>} tag loads as an empty string, 
which must still be
+   * treated as "compare with the constant" and not as a field named "".
+   */
+  @Test
+  void emptyRightValueNameShowsConstant() throws Exception {
+    String xml =
+        "<condition>"
+            + "<negated>N</negated>"
+            + "<leftvalue>deviation</leftvalue>"
+            + "<function>&lt;</function>"
+            + "<rightvalue/>"
+            + "<value>"
+            + "<name>constant</name>"
+            + "<type>Number</type>"
+            + "<text>-0.1</text>"
+            + "<length>-1</length>"
+            + "<precision>-1</precision>"
+            + "<isnull>N</isnull>"
+            + "</value>"
+            + "</condition>";
+    Condition condition = new Condition(xml);
+
+    assertTrue(condition.toString().contains("deviation < [-0.1]"), 
condition.toString());
+    assertEquals(1, condition.getUsedFields().length);
+    assertEquals("deviation", condition.getUsedFields()[0]);
+  }
+
   @Test
   void dateConstantWithMatchingMaskEvaluates() throws Exception {
     Condition condition = dateLessThanConstant("2022-01-01", "yyyy-MM-dd");
diff --git 
a/ui/src/main/java/org/apache/hop/ui/core/widget/ConditionEditor.java 
b/ui/src/main/java/org/apache/hop/ui/core/widget/ConditionEditor.java
index c09c923cf3..3460b3c8c8 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/widget/ConditionEditor.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/widget/ConditionEditor.java
@@ -24,6 +24,7 @@ import static org.apache.hop.core.Condition.Operator.NONE;
 import static org.apache.hop.core.Condition.Operator.lookupType;
 
 import java.util.ArrayList;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.hop.core.Condition;
 import org.apache.hop.core.Const;
 import org.apache.hop.core.exception.HopXmlException;
@@ -968,7 +969,7 @@ public class ConditionEditor extends Canvas implements 
MouseMoveListener {
           stype = " (" + v.createValueMeta().getTypeDesc() + ")";
         }
 
-        if (condition.getRightValueName() != null) {
+        if (StringUtils.isNotEmpty(condition.getRightValueName())) {
           gc.drawText(
               rightval,
               sizeRightval.x + 1 + offsetx,
@@ -982,7 +983,7 @@ public class ConditionEditor extends Canvas implements 
MouseMoveListener {
               sizeRightval.x + 1 + offsetx,
               sizeRightval.y + 1 + offsety,
               SWT.DRAW_TRANSPARENT);
-          if (condition.getRightValueName() == null) {
+          if (StringUtils.isEmpty(condition.getRightValueName())) {
             gc.setForeground(black);
           }
         }
@@ -991,7 +992,7 @@ public class ConditionEditor extends Canvas implements 
MouseMoveListener {
           gc.drawText(
               re, sizeRightex.x + 1 + offsetx, sizeRightex.y + 1 + offsety, 
SWT.DRAW_TRANSPARENT);
         } else {
-          String nothing = condition.getRightValueName() == null ? "<value>" : 
"";
+          String nothing = StringUtils.isEmpty(condition.getRightValueName()) 
? "<value>" : "";
           gc.setForeground(gray);
           gc.drawText(
               nothing,

Reply via email to