Skip to content

Commit

Permalink
Merge pull request #671 from alvasw/persistable_store_reader_writer_t…
Browse files Browse the repository at this point in the history
…hread_safe

Make PersistableStoreReaderWriter thread-safe
  • Loading branch information
alvasw authored Mar 2, 2023
2 parents 7024fd9 + 79cc51f commit 8852482
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public PersistableStoreReaderWriter(PersistableStoreFileManager storeFileManager
this.parentDirectoryPath = storeFilePath.getParent();
}

public Optional<T> read() {
public synchronized Optional<T> read() {
File storeFile = storeFilePath.toFile();
if (!storeFile.exists()) {
return Optional.empty();
Expand All @@ -60,7 +60,7 @@ public Optional<T> read() {
return Optional.empty();
}

public void write(T persistableStore) {
public synchronized void write(T persistableStore) {
storeFileManager.createParentDirectoriesIfNotExisting();

try {
Expand Down

0 comments on commit 8852482

Please sign in to comment.