Synchronize on the class instead of the instance

I didn't realize it before, but it looks like there is at least one instance of YamlRegionFile per world, so synchronizing on the instance wouldn't necessarily help.
This commit is contained in:
TomyLobo 2023-06-12 03:16:14 +02:00
parent 7ba0fd3f53
commit 5763f53415
1 changed files with 49 additions and 47 deletions

View File

@ -192,9 +192,10 @@ public class YamlRegionFile implements RegionDatabase {
}
@Override
public synchronized void saveAll(Set<ProtectedRegion> regions) throws StorageException {
public void saveAll(Set<ProtectedRegion> regions) throws StorageException {
checkNotNull(regions);
synchronized (YamlRegionFile.class) {
File tempFile = new File(file.getParentFile(), file.getName() + ".tmp");
YAMLProcessor config = createYamlProcessor(tempFile);
@ -254,6 +255,7 @@ public class YamlRegionFile implements RegionDatabase {
throw new StorageException("Failed to rename temporary regions file to " + file.getAbsolutePath());
}
}
}
@Override
public void saveChanges(RegionDifference difference) throws DifferenceSaveException {