From d2fe2a09de6881ce6ce949c8e99bec7825c5c833 Mon Sep 17 00:00:00 2001 From: Ohad Shai Date: Mon, 11 Apr 2022 20:46:00 +0300 Subject: [PATCH] =?UTF-8?q?fix(test):=20replace=20HashMap=20with=20Concurr?= =?UTF-8?q?entHashMap=20to=20avoid=20ConcurrentModificatio=E2=80=A6=20(#88?= =?UTF-8?q?3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Owl Bot --- .../contrib/nio/testing/FakeStorageRpc.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java index b044988913..03d1e38d45 100644 --- a/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java +++ b/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/testing/FakeStorageRpc.java @@ -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; /** @@ -77,11 +77,11 @@ class FakeStorageRpc extends StorageRpcTestBase { new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX"); // fullname -> metadata - Map metadata = new HashMap<>(); + Map metadata = new ConcurrentHashMap<>(); // fullname -> contents - Map contents = new HashMap<>(); + Map contents = new ConcurrentHashMap<>(); // fullname -> future contents that will be visible on close. - Map futureContents = new HashMap<>(); + Map futureContents = new ConcurrentHashMap<>(); private final boolean throwIfOption; @@ -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 @@ -149,7 +149,7 @@ public Tuple> list(String bucket, Map final String prefix = preprefix; List values = new ArrayList<>(); - Map folders = new HashMap<>(); + Map folders = new ConcurrentHashMap<>(); for (StorageObject so : metadata.values()) { if (!so.getBucket().equals(bucket) || !so.getName().startsWith(prefix)) { continue;