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

replace HashMap with ConcurrentHashMap to avoid ConcurrentModificatio… #883

Merged
merged 2 commits into from
Apr 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.concurrent.NotThreadSafe;

/**
Expand Down Expand Up @@ -77,11 +77,11 @@ class FakeStorageRpc extends StorageRpcTestBase {
new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX");

// fullname -> metadata
Map<String, StorageObject> metadata = new HashMap<>();
Map<String, StorageObject> metadata = new ConcurrentHashMap<>();
// fullname -> contents
Map<String, byte[]> contents = new HashMap<>();
Map<String, byte[]> contents = new ConcurrentHashMap<>();
// fullname -> future contents that will be visible on close.
Map<String, byte[]> futureContents = new HashMap<>();
Map<String, byte[]> futureContents = new ConcurrentHashMap<>();

private final boolean throwIfOption;

Expand All @@ -92,8 +92,8 @@ public FakeStorageRpc(boolean throwIfOption) {

// remove all files
void reset() {
metadata = new HashMap<>();
contents = new HashMap<>();
metadata = new ConcurrentHashMap<>();
contents = new ConcurrentHashMap<>();
}

@Override
Expand Down Expand Up @@ -149,7 +149,7 @@ public Tuple<String, Iterable<StorageObject>> list(String bucket, Map<Option, ?>
final String prefix = preprefix;

List<StorageObject> values = new ArrayList<>();
Map<String, StorageObject> folders = new HashMap<>();
Map<String, StorageObject> folders = new ConcurrentHashMap<>();
for (StorageObject so : metadata.values()) {
if (!so.getBucket().equals(bucket) || !so.getName().startsWith(prefix)) {
continue;
Expand Down