Skip to content

HDFS-16537.Fix oev decode xml error#8311

Open
GuoPhilipse wants to merge 25 commits intoapache:trunkfrom
GuoPhilipse:fixoeverrornew
Open

HDFS-16537.Fix oev decode xml error#8311
GuoPhilipse wants to merge 25 commits intoapache:trunkfrom
GuoPhilipse:fixoeverrornew

Conversation

@GuoPhilipse
Copy link
Member

JIRA:HDFS-16537

Copilot AI review requested due to automatic review settings March 8, 2026 01:06
@GuoPhilipse
Copy link
Member Author

For the old pr "#4160" not follow the latest branch, so i create a new pr for it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses HDFS-16537 by fixing XML decoding for FSEditLogOp.TruncateOp (used by Offline Edits Viewer / XML-based edit log parsing) and adds regression tests to validate correct truncateBlock parsing behavior.

Changes:

  • Update TruncateOp#fromXml to parse the <BLOCK> stanza as a child element rather than the root stanza.
  • Add unit tests covering XML decoding with and without a <BLOCK> stanza for TruncateOp.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSEditLogOp.java Adds regression coverage for TruncateOp#fromXml behavior with/without <BLOCK>.
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java Fixes TruncateOp#fromXml to read block fields from the <BLOCK> child stanza.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

import org.apache.hadoop.hdfs.protocol.Block;
import org.apache.hadoop.hdfs.util.XMLUtils.InvalidXmlException;
import org.apache.hadoop.hdfs.util.XMLUtils.Stanza;
import org.junit.Test;
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test class mixes JUnit 5 assertions with a JUnit 4 @Test annotation (org.junit.Test). In this module most tests use JUnit Jupiter annotations (e.g., TestAddBlock.java imports org.junit.jupiter.api.Test), and mixing frameworks can cause tests not to be discovered depending on the configured runner. Switch to org.junit.jupiter.api.Test (or consistently use JUnit 4 assertions/runner) to match the existing test setup.

Suggested change
import org.junit.Test;
import org.junit.jupiter.api.Test;

Copilot uses AI. Check for mistakes.
Comment on lines 2944 to 2950
this.clientName = st.getValue("CLIENTNAME");
this.clientMachine = st.getValue("CLIENTMACHINE");
this.newLength = Long.parseLong(st.getValue("NEWLENGTH"));
this.timestamp = Long.parseLong(st.getValue("TIMESTAMP"));
if (st.hasChildren("BLOCK"))
this.truncateBlock = FSEditLogOp.blockFromXml(st);
this.truncateBlock = FSEditLogOp.blockFromXml(st.getChildren("BLOCK").get(0));
}
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TruncateOp#fromXml only updates truncateBlock when a stanza is present; if the stanza is missing, truncateBlock retains its previous value. This breaks XML decoding correctness (and should fail the new test that expects truncateBlock to be reset to null). Consider explicitly clearing truncateBlock at the start of fromXml (and/or in resetSubFields) and validating there is exactly one BLOCK child before parsing (consistent with the <=1 block invariant used in readFields).

Copilot uses AI. Check for mistakes.
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 21s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 26m 29s trunk passed
+1 💚 compile 0m 55s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 0m 56s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 1m 0s trunk passed
+1 💚 mvnsite 1m 6s trunk passed
+1 💚 javadoc 0m 50s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 55s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 2m 11s trunk passed
+1 💚 shadedclient 16m 38s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
-1 ❌ mvninstall 0m 16s /patch-mvninstall-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
-1 ❌ compile 0m 18s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-21.0.10+7-Ubuntu-124.04.txt hadoop-hdfs in the patch failed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04.
-1 ❌ javac 0m 18s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-21.0.10+7-Ubuntu-124.04.txt hadoop-hdfs in the patch failed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04.
-1 ❌ compile 0m 17s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-17.0.18+8-Ubuntu-124.04.1.txt hadoop-hdfs in the patch failed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1.
-1 ❌ javac 0m 17s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-17.0.18+8-Ubuntu-124.04.1.txt hadoop-hdfs in the patch failed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1.
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 41s the patch passed
-1 ❌ mvnsite 0m 19s /patch-mvnsite-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
-1 ❌ javadoc 0m 19s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-21.0.10+7-Ubuntu-124.04.txt hadoop-hdfs in the patch failed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04.
-1 ❌ javadoc 0m 19s /patch-javadoc-hadoop-hdfs-project_hadoop-hdfs-jdkUbuntu-17.0.18+8-Ubuntu-124.04.1.txt hadoop-hdfs in the patch failed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1.
-1 ❌ spotbugs 0m 19s /patch-spotbugs-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
-1 ❌ shadedclient 8m 2s patch has errors when building and testing our client artifacts.
_ Other Tests _
-1 ❌ unit 0m 18s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch failed.
+1 💚 asflicense 0m 19s The patch does not generate ASF License warnings.
60m 45s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8311/1/artifact/out/Dockerfile
GITHUB PR #8311
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 9f5909a83ed6 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 044215e
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8311/1/testReport/
Max. process+thread count 614 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8311/1/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 20s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 27m 22s trunk passed
+1 💚 compile 0m 53s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 0m 55s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 0m 56s trunk passed
+1 💚 mvnsite 0m 57s trunk passed
+1 💚 javadoc 0m 49s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 54s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 2m 8s trunk passed
+1 💚 shadedclient 17m 59s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 43s the patch passed
+1 💚 compile 0m 42s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 0m 42s the patch passed
+1 💚 compile 0m 44s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 0m 44s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 41s hadoop-hdfs-project/hadoop-hdfs: The patch generated 0 new + 323 unchanged - 2 fixed = 323 total (was 325)
+1 💚 mvnsite 0m 50s the patch passed
+1 💚 javadoc 0m 34s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 37s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 2m 18s the patch passed
+1 💚 shadedclient 17m 32s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 175m 26s hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 29s The patch does not generate ASF License warnings.
253m 4s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8311/2/artifact/out/Dockerfile
GITHUB PR #8311
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 33d70771f77e 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 079bfff
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8311/2/testReport/
Max. process+thread count 4144 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8311/2/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

@GuoPhilipse
Copy link
Member Author

cc @hfutatzhanghb @ayushtkn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants