This is an automated email from the ASF dual-hosted git repository.
hansva 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 3ee66b3f81 treat empty tag as empty string and not null, fixes #7045
(#7087)
3ee66b3f81 is described below
commit 3ee66b3f8165de047026a7d052fdd5c983f3cd0e
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Mon May 4 14:33:49 2026 +0200
treat empty tag as empty string and not null, fixes #7045 (#7087)
---
.../apache/hop/metadata/serializer/xml/XmlMetadataUtil.java | 13 +++++++++----
.../java/org/apache/hop/workflow/action/ActionBase.java | 9 ---------
plugins/misc/git/src/test/resources/r2.hpl | 1 +
.../getfilesrowcount/GetFilesRowsCountMetaTest.java | 5 ++---
.../hop/pipeline/transforms/ifnull/IfNullMetaTest.java | 9 ++++-----
.../pipelineexecutor/PipelineExecutorMetaTest.java | 3 +--
.../transforms/splunkinput/SplunkInputMetaTest.java | 2 +-
.../transforms/textfileoutput/TextFileOutputMeta.java | 4 ----
.../transforms/valuemapper/ValueMapperMetaTest.java | 3 +--
9 files changed, 19 insertions(+), 30 deletions(-)
diff --git
a/core/src/main/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtil.java
b/core/src/main/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtil.java
index ab867ec744..bb5fe1bf98 100644
---
a/core/src/main/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtil.java
+++
b/core/src/main/java/org/apache/hop/metadata/serializer/xml/XmlMetadataUtil.java
@@ -1073,25 +1073,30 @@ public class XmlMetadataUtil {
IHopMetadataProvider metadataProvider)
throws HopXmlException {
if (elementNode != null) {
+ // The element is present in the XML, so the user intended a value —
even if it's empty.
+ // <tag/> and <tag></tag> both have no text children, which makes
XmlHandler.getNodeValue
+ // return null; collapse that to "" so the field assignment below isn't
skipped by the
+ // null-guard in the caller (which would otherwise leave the constructor
default in place).
+ String value = elementString != null ? elementString : "";
if (parentProperty.password()) {
- return Encr.decryptPasswordOptionallyEncrypted(elementString);
+ return Encr.decryptPasswordOptionallyEncrypted(value);
}
if (!EmptyStringEncoder.class.equals(parentProperty.stringEncoder())) {
// Decode the encoded string
//
try {
IStringEncoder encoder =
parentProperty.stringEncoder().getConstructor().newInstance();
- return encoder.decode(elementString);
+ return encoder.decode(value);
} catch (Exception e) {
throw new HopXmlException(
"Error decoding string '"
- + elementString
+ + value
+ "' with string encoder class "
+ parentProperty.stringEncoder().getName(),
e);
}
} else {
- return elementString;
+ return value;
}
}
return null;
diff --git
a/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java
b/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java
index a71e7f1822..456c0a8400 100644
--- a/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java
+++ b/engine/src/main/java/org/apache/hop/workflow/action/ActionBase.java
@@ -127,8 +127,6 @@ public abstract class ActionBase
protected WorkflowMeta parentWorkflowMeta;
- private static final String CONST_SPACE = " ";
-
/** Instantiates a new action base object. */
protected ActionBase() {
name = null;
@@ -344,14 +342,7 @@ public abstract class ActionBase
@Override
public String getXml() {
StringBuilder xml = new StringBuilder();
- xml.append(CONST_SPACE).append(XmlHandler.addTagValue("name", getName()));
- xml.append(CONST_SPACE).append(XmlHandler.addTagValue("description",
getDescription()));
- xml.append(CONST_SPACE).append(XmlHandler.addTagValue("type", pluginId));
-
xml.append(AttributesUtil.getAttributesXml(attributesMap));
-
- // Try to serialize the rest of the @HopMetadataProperty fields...
- //
try {
xml.append(XmlMetadataUtil.serializeObjectToXml(this));
} catch (HopException e) {
diff --git a/plugins/misc/git/src/test/resources/r2.hpl
b/plugins/misc/git/src/test/resources/r2.hpl
index 7811a76e7d..1b6c5017e0 100644
--- a/plugins/misc/git/src/test/resources/r2.hpl
+++ b/plugins/misc/git/src/test/resources/r2.hpl
@@ -45,6 +45,7 @@ limitations under the License.
<distribute>Y</distribute>
<fields>
</fields>
+<resultfieldName/>
<resultType>hexadecimal</resultType>
<checksumtype>CRC32</checksumtype>
<partitioning>
diff --git
a/plugins/transforms/getfilesrowcount/src/test/java/org/apache/hop/pipeline/transforms/getfilesrowcount/GetFilesRowsCountMetaTest.java
b/plugins/transforms/getfilesrowcount/src/test/java/org/apache/hop/pipeline/transforms/getfilesrowcount/GetFilesRowsCountMetaTest.java
index ad611c2c90..30bacee549 100644
---
a/plugins/transforms/getfilesrowcount/src/test/java/org/apache/hop/pipeline/transforms/getfilesrowcount/GetFilesRowsCountMetaTest.java
+++
b/plugins/transforms/getfilesrowcount/src/test/java/org/apache/hop/pipeline/transforms/getfilesrowcount/GetFilesRowsCountMetaTest.java
@@ -19,7 +19,6 @@ package org.apache.hop.pipeline.transforms.getfilesrowcount;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.hop.pipeline.transform.TransformSerializationTestUtil;
@@ -35,14 +34,14 @@ class GetFilesRowsCountMetaTest {
assertEquals("filesCount", meta.getFilesCountFieldName());
assertEquals("rowsCount", meta.getRowsCountFieldName());
assertEquals(GetFilesRowsCountMeta.SeparatorFormat.LF,
meta.getRowSeparatorFormat());
- assertNull(meta.getRowSeparator());
+ assertEquals("", meta.getRowSeparator());
assertTrue(meta.isIncludeFilesCount());
assertTrue(meta.isAddResultFilename());
assertFalse(meta.isFileFromField());
assertEquals(1, meta.getFiles().size());
assertEquals("${PROJECT_HOME}/files/", meta.getFiles().get(0).getName());
assertEquals(".*\\.txt$", meta.getFiles().get(0).getMask());
- assertNull(meta.getFiles().get(0).getExcludeMask());
+ assertEquals("", meta.getFiles().get(0).getExcludeMask());
assertTrue(meta.getFiles().get(0).isRequired());
assertTrue(meta.getFiles().get(0).isIncludeSubFolder());
}
diff --git
a/plugins/transforms/ifnull/src/test/java/org/apache/hop/pipeline/transforms/ifnull/IfNullMetaTest.java
b/plugins/transforms/ifnull/src/test/java/org/apache/hop/pipeline/transforms/ifnull/IfNullMetaTest.java
index c017a10227..3c8b3841b7 100644
---
a/plugins/transforms/ifnull/src/test/java/org/apache/hop/pipeline/transforms/ifnull/IfNullMetaTest.java
+++
b/plugins/transforms/ifnull/src/test/java/org/apache/hop/pipeline/transforms/ifnull/IfNullMetaTest.java
@@ -18,7 +18,6 @@ package org.apache.hop.pipeline.transforms.ifnull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.hop.core.HopEnvironment;
@@ -51,13 +50,13 @@ class IfNullMetaTest {
assertEquals(0, meta.getFields().size());
assertEquals("String", meta.getValueTypes().get(0).getName());
- assertNull(meta.getValueTypes().get(0).getValue());
+ assertEquals("", meta.getValueTypes().get(0).getValue());
assertTrue(meta.getValueTypes().get(0).isSetEmptyString());
assertEquals("Number", meta.getValueTypes().get(1).getName());
- assertNull(meta.getValueTypes().get(1).getValue());
+ assertEquals("", meta.getValueTypes().get(1).getValue());
assertFalse(meta.getValueTypes().get(1).isSetEmptyString());
assertEquals("Date", meta.getValueTypes().get(2).getName());
- assertNull(meta.getValueTypes().get(2).getValue());
+ assertEquals("", meta.getValueTypes().get(2).getValue());
assertFalse(meta.getValueTypes().get(2).isSetEmptyString());
}
@@ -80,7 +79,7 @@ class IfNullMetaTest {
assertEquals("ddMMYYYY", meta.getFields().get(1).getMask());
assertFalse(meta.getFields().get(1).isSetEmptyString());
assertEquals("F3", meta.getFields().get(2).getName());
- assertNull(meta.getFields().get(2).getValue());
+ assertEquals("", meta.getFields().get(2).getValue());
assertTrue(meta.getFields().get(2).isSetEmptyString());
}
diff --git
a/plugins/transforms/pipelineexecutor/src/test/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutorMetaTest.java
b/plugins/transforms/pipelineexecutor/src/test/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutorMetaTest.java
index a5baf02252..cddde3a02a 100644
---
a/plugins/transforms/pipelineexecutor/src/test/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutorMetaTest.java
+++
b/plugins/transforms/pipelineexecutor/src/test/java/org/apache/hop/pipeline/transforms/pipelineexecutor/PipelineExecutorMetaTest.java
@@ -20,7 +20,6 @@ package org.apache.hop.pipeline.transforms.pipelineexecutor;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.hop.core.exception.HopException;
@@ -54,7 +53,7 @@ class PipelineExecutorMetaTest {
assertEquals("ExecutionExitStatus", meta.getExecutionExitStatusField());
assertEquals("ExecutionLogText", meta.getExecutionLogTextField());
assertEquals("ExecutionLogChannelId",
meta.getExecutionLogChannelIdField());
- assertNull(meta.getOutputRowsSourceTransform());
+ assertEquals("", meta.getOutputRowsSourceTransform());
assertEquals("result file names after execution",
meta.getResultFilesTargetTransform());
assertEquals("FileName", meta.getResultFilesFileNameField());
assertEquals("copy of input rows", meta.getExecutorsOutputTransform());
diff --git
a/plugins/transforms/splunk/src/test/java/org/apache/hop/pipeline/transforms/splunkinput/SplunkInputMetaTest.java
b/plugins/transforms/splunk/src/test/java/org/apache/hop/pipeline/transforms/splunkinput/SplunkInputMetaTest.java
index 0153ade179..77a5c4655d 100644
---
a/plugins/transforms/splunk/src/test/java/org/apache/hop/pipeline/transforms/splunkinput/SplunkInputMetaTest.java
+++
b/plugins/transforms/splunk/src/test/java/org/apache/hop/pipeline/transforms/splunkinput/SplunkInputMetaTest.java
@@ -51,7 +51,7 @@ class SplunkInputMetaTest {
Assertions.assertEquals("splunkField1", v1.getSplunkName());
Assertions.assertEquals("String", v1.getType());
Assertions.assertEquals(10, v1.getLength());
- Assertions.assertNull(v1.getFormat());
+ Assertions.assertEquals("", v1.getFormat());
ReturnValue v2 = meta.getReturnValues().get(1);
Assertions.assertEquals("field2", v2.getName());
diff --git
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputMeta.java
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputMeta.java
index 8346439fed..7ef0d6c8e2 100644
---
a/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputMeta.java
+++
b/plugins/transforms/textfile/src/main/java/org/apache/hop/pipeline/transforms/textfileoutput/TextFileOutputMeta.java
@@ -71,10 +71,6 @@ public class TextFileOutputMeta extends
BaseTransformMeta<TextFileOutput, TextFi
protected static final String[] formatMapperLineTerminator =
new String[] {"DOS", "UNIX", "CR", "None"};
- public static final String CONST_FORMAT = "format";
- public static final String CONST_FIELD = "field";
- public static final String CONST_SPACES_LONG = " ";
- public static final String CONST_SPACES = " ";
@Getter
@Setter
diff --git
a/plugins/transforms/valuemapper/src/test/java/org/apache/hop/pipeline/transforms/valuemapper/ValueMapperMetaTest.java
b/plugins/transforms/valuemapper/src/test/java/org/apache/hop/pipeline/transforms/valuemapper/ValueMapperMetaTest.java
index 40562ee6cc..e1a45eb310 100644
---
a/plugins/transforms/valuemapper/src/test/java/org/apache/hop/pipeline/transforms/valuemapper/ValueMapperMetaTest.java
+++
b/plugins/transforms/valuemapper/src/test/java/org/apache/hop/pipeline/transforms/valuemapper/ValueMapperMetaTest.java
@@ -101,8 +101,7 @@ class ValueMapperMetaTest {
"/value-mapper-transform.xml", ValueMapperMeta.class);
assertEquals(7, meta.getValues().size());
- // Test serialization with null source attribute
- assertNull(meta.getValues().get(0).getSource());
+ assertEquals("", meta.getValues().get(0).getSource());
assertEquals("[${NOT_DEFINED}]", meta.getValues().get(0).getTarget());
assertEquals("BE", meta.getValues().get(1).getSource());