Synchronize YamlRegionFile#saveAll

This prevents multiple invocations of the method from intersecting, which could potentially cause the .tmp file to be overwritten before being renamed, thus corrupting the region storage
This commit is contained in:
TomyLobo 2023-06-11 00:07:43 +02:00
parent 8cbce96a2c
commit 7ba0fd3f53

View File

@ -192,7 +192,7 @@ public Set<ProtectedRegion> loadAll(FlagRegistry flagRegistry) throws StorageExc
} }
@Override @Override
public void saveAll(Set<ProtectedRegion> regions) throws StorageException { public synchronized void saveAll(Set<ProtectedRegion> regions) throws StorageException {
checkNotNull(regions); checkNotNull(regions);
File tempFile = new File(file.getParentFile(), file.getName() + ".tmp"); File tempFile = new File(file.getParentFile(), file.getName() + ".tmp");