You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by er...@apache.org on 2022/04/14 10:03:13 UTC
[iotdb] 01/01: [IOTDB-2921] Fix WALNodeTest of concurrently accessing ArrayList
This is an automated email from the ASF dual-hosted git repository.
ericpai pushed a commit to branch bugfix/iotdb-2921
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 628ed1e75a768e9d0dad3f0d546d41c6432a3f5a
Author: ericpai <er...@hotmail.com>
AuthorDate: Thu Apr 14 18:02:51 2022 +0800
[IOTDB-2921] Fix WALNodeTest of concurrently accessing ArrayList
---
.../src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java b/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java
index a4e249cd80..0705c39794 100644
--- a/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/wal/node/WALNodeTest.java
@@ -42,6 +42,7 @@ import org.junit.Test;
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -52,7 +53,11 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class WALNodeTest {
private static final IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
@@ -83,7 +88,7 @@ public class WALNodeTest {
int threadsNum = 3;
ExecutorService executorService = Executors.newFixedThreadPool(threadsNum);
List<Future<Void>> futures = new ArrayList<>();
- List<WALFlushListener> walFlushListeners = new ArrayList<>();
+ List<WALFlushListener> walFlushListeners = Collections.synchronizedList(new ArrayList<>());
Set<InsertTabletPlan> expectedInsertTabletPlans = ConcurrentHashMap.newKeySet();
for (int i = 0; i < threadsNum; ++i) {
int memTableId = i;