Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize YamlRegionFile#saveAll #2014

Open
wants to merge 11 commits into
base: version/7.0.x
Choose a base branch
from
Prev Previous commit
Next Next commit
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
TomyLobo committed Jul 19, 2023

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
commit 7ba0fd3f5360a179d375cc315fa1f8c3e41d2ae7
Original file line number Diff line number Diff line change
@@ -192,7 +192,7 @@ public Set<ProtectedRegion> loadAll(FlagRegistry flagRegistry) throws StorageExc
}

@Override
public void saveAll(Set<ProtectedRegion> regions) throws StorageException {
public synchronized void saveAll(Set<ProtectedRegion> regions) throws StorageException {
checkNotNull(regions);

File tempFile = new File(file.getParentFile(), file.getName() + ".tmp");