slfan1989 commented on code in PR #8995:
URL: https://github.com/apache/hadoop/pull/8995#discussion_r4606961890
##########
hadoop-tools/hadoop-distcp/src/main/java/org/apache/hadoop/tools/CopyListingFileStatus.java:
##########
@@ -255,7 +257,16 @@ public Map<String, byte[]> getXAttrs() {
* @param xAttrs Map containing all xAttrs
*/
public void setXAttrs(Map<String, byte[]> xAttrs) {
- this.xAttrs = xAttrs;
+ if (xAttrs == null) {
+ this.xAttrs = null;
+ return;
+ }
+ Map<String, byte[]> copy = new LinkedHashMap<>(xAttrs.size());
+ for (Entry<String, byte[]> entry : xAttrs.entrySet()) {
+ byte[] value = entry.getValue();
+ copy.put(entry.getKey(), value == null ? null : value.clone());
Review Comment:
The deep copy fixes the aliasing issue.
It also changes `CopyListingFileStatus.equals()`: two instances with the
same path and ACLs that receive the same XAttr map now compare unequal when it
contains a non-null value, because `Map.equals()` compares the cloned `byte[]`
values by identity.
Could we compare XAttr values by byte content, keep `hashCode()` consistent,
and add a regression test for this case?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]