mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-19 22:51:41 +01:00
Synchronize cache access
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
85559abb28
commit
ac4d78acf1
@ -111,20 +111,20 @@ final class TagHandlerImpl implements TagHandler {
|
||||
}
|
||||
entries[index] = new Entry<>(tag, nbt);
|
||||
}
|
||||
synchronized (this) {
|
||||
this.cache = null;
|
||||
this.entries = entries;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull NBTCompound asCompound() {
|
||||
return updatedCache().compound;
|
||||
}
|
||||
|
||||
private Cache updatedCache() {
|
||||
private synchronized Cache updatedCache() {
|
||||
Cache cache = this.cache;
|
||||
if (cache == null) {
|
||||
synchronized (this) {
|
||||
if ((cache = this.cache) != null) return cache;
|
||||
Entry<?>[] entries = this.entries;
|
||||
if (entries.length > 0) {
|
||||
entries = entries.clone();
|
||||
@ -146,7 +146,6 @@ final class TagHandlerImpl implements TagHandler {
|
||||
}
|
||||
this.cache = cache;
|
||||
}
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user