HDFS-16537.Fix oev decode xml error#8311
Conversation
|
For the old pr "#4160" not follow the latest branch, so i create a new pr for it. |
There was a problem hiding this comment.
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#fromXmlto 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 forTruncateOp.
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; |
There was a problem hiding this comment.
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.
| import org.junit.Test; | |
| import org.junit.jupiter.api.Test; |
| 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)); | ||
| } |
There was a problem hiding this comment.
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).
|
💔 -1 overall
This message was automatically generated. |
|
🎊 +1 overall
This message was automatically generated. |
JIRA:HDFS-16537