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:
parent
c40a6bd46a
commit
7c941e00b4
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user