This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 8f301d057a [core] fix Bug-NullPointException when readHadoopXml, for
issue#6282 #6302 (#6361)
8f301d057a is described below
commit 8f301d057a35d4292b3046c998fdd92b4c4e2153
Author: linqichen178 <[email protected]>
AuthorDate: Sun May 24 10:22:30 2026 +0800
[core] fix Bug-NullPointException when readHadoopXml, for issue#6282 #6302
(#6361)
---
.../java/org/apache/paimon/utils/HadoopUtils.java | 18 ++++++++++++------
.../org/apache/paimon/utils/HadoopUtilsITCase.java | 20 ++++++++++++++++++++
2 files changed, 32 insertions(+), 6 deletions(-)
diff --git
a/paimon-common/src/main/java/org/apache/paimon/utils/HadoopUtils.java
b/paimon-common/src/main/java/org/apache/paimon/utils/HadoopUtils.java
index be25fce4d2..a37c64dbb8 100644
--- a/paimon-common/src/main/java/org/apache/paimon/utils/HadoopUtils.java
+++ b/paimon-common/src/main/java/org/apache/paimon/utils/HadoopUtils.java
@@ -221,13 +221,19 @@ public class HadoopUtils {
}
for (int i = 0; i < propertyNodes.getLength(); i++) {
Node propertyNode = propertyNodes.item(i);
- if (propertyNode.getNodeType() == 1) {
+ if (1 == propertyNode.getNodeType()) {
Element propertyElement = (Element) propertyNode;
- String key =
propertyElement.getElementsByTagName("name").item(0).getTextContent();
- String value =
-
propertyElement.getElementsByTagName("value").item(0).getTextContent();
- if (!StringUtils.isNullOrWhitespaceOnly(value)) {
- conf.set(key, value);
+ if (null != propertyElement.getElementsByTagName("name")
+ && null !=
propertyElement.getElementsByTagName("name").item(0)
+ && null !=
propertyElement.getElementsByTagName("value")
+ && null !=
propertyElement.getElementsByTagName("value").item(0)) {
+ String name =
+
propertyElement.getElementsByTagName("name").item(0).getTextContent();
+ String value =
+
propertyElement.getElementsByTagName("value").item(0).getTextContent();
+ if (!StringUtils.isNullOrWhitespaceOnly(value)) {
+ conf.set(name, value);
+ }
}
}
}
diff --git
a/paimon-common/src/test/java/org/apache/paimon/utils/HadoopUtilsITCase.java
b/paimon-common/src/test/java/org/apache/paimon/utils/HadoopUtilsITCase.java
index 312ea96fef..2fa50244b6 100644
--- a/paimon-common/src/test/java/org/apache/paimon/utils/HadoopUtilsITCase.java
+++ b/paimon-common/src/test/java/org/apache/paimon/utils/HadoopUtilsITCase.java
@@ -70,4 +70,24 @@ public class HadoopUtilsITCase {
return LocalFileIO.create();
}
}
+
+ @Test
+ public void testReadHadoopXml() {
+ String xml =
+ "<configuration><property>"
+ + "<name>paimon.test.key0</name>"
+ + "</property>"
+ + "<property>"
+ + "<name>paimon.test.key1</name>"
+ + "<value/>"
+ + "</property>"
+ + "<property>"
+ + "<name>paimon.test.key2</name>"
+ + "<value>test.value</value>"
+ + "</property>"
+ + "</configuration>";
+ Configuration conf = new Configuration();
+ HadoopUtils.readHadoopXml(xml, conf);
+ assertThat(conf.get("paimon.test.key2")).isEqualTo("test.value");
+ }
}