HDFS-16933. A race in SerialNumberMap will cause wrong owner, group and XATTR. (#5430). Contributed by ZanderXu.

Signed-off-by: He Xiaoqiao <hexiaoqiao@apache.org>
This commit is contained in:
ZanderXu 2023-09-06 10:27:52 +08:00 committed by GitHub
parent c40a6bd46a
commit 7c941e00b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,6 +60,9 @@ public int get(T t) {
return 0;
}
Integer sn = t2i.get(t);
if (sn == null) {
synchronized (this) {
sn = t2i.get(t);
if (sn == null) {
sn = current.getAndIncrement();
if (sn > max) {
@ -73,6 +76,8 @@ public int get(T t) {
}
i2t.put(sn, t);
}
}
}
return sn;
}