[
https://issues.apache.org/jira/browse/HDFS-16537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18063833#comment-18063833
]
ASF GitHub Bot commented on HDFS-16537:
---------------------------------------
Copilot commented on code in PR #8311:
URL: https://github.com/apache/hadoop/pull/8311#discussion_r2900994300
##########
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java:
##########
@@ -2946,7 +2946,7 @@ void fromXml(Stanza st) throws InvalidXmlException {
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));
}
Review Comment:
TruncateOp#fromXml only updates truncateBlock when a <BLOCK> 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).
##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestFSEditLogOp.java:
##########
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdfs.server.namenode;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+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;
Review 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.
```suggestion
import org.junit.jupiter.api.Test;
```
> oev parse error when we have truncate operate
> ----------------------------------------------
>
> Key: HDFS-16537
> URL: https://issues.apache.org/jira/browse/HDFS-16537
> Project: Hadoop HDFS
> Issue Type: Improvement
> Components: hdfs
> Affects Versions: 3.3.2
> Reporter: guophilipse
> Priority: Major
> Labels: pull-request-available
> Attachments: image-2022-04-11-17-33-46-669.png
>
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> hi ,when we use oev tool to parse xml to fsimage file , and the xml contains
> OP_TRUNCATE ,the decode parse will fail with the following error
> !image-2022-04-11-17-33-46-669.png!
> the truncate record example as the following.
> <RECORD>
> <OPCODE>OP_TRUNCATE</OPCODE>
> <DATA>
> <TXID>4169074186</TXID>
> <SRC>/data/test/2022/03/24/part-9-123</SRC>
> <CLIENTNAME>DFSClient_NONMAPREDUCE_2025317379_1</CLIENTNAME>
> <CLIENTMACHINE>192.168.1.1</CLIENTMACHINE>
> <NEWLENGTH>3462890</NEWLENGTH>
> <TIMESTAMP>1648094066932</TIMESTAMP>
> <BLOCK>
> <BLOCK_ID>1369315031</BLOCK_ID>
> <NUM_BYTES>0</NUM_BYTES>
> <GENSTAMP>296479647</GENSTAMP>
> </BLOCK>
> </DATA>
> </RECORD>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]