From 168d9f949bef682a60597a7e10b39f6aeb9ff36b Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sun, 24 Nov 2024 20:26:11 +0100 Subject: [PATCH] Make use of CopyOnWriteArray instead This is automatically safe for iterations (which Collections.synchronizedList is not) and it makes more sense for our use case given the rarity of our writes --- src/main/java/com/questhelper/panel/QuestOverviewPanel.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/questhelper/panel/QuestOverviewPanel.java b/src/main/java/com/questhelper/panel/QuestOverviewPanel.java index a2ad8d7f9a..ff3b3b284f 100644 --- a/src/main/java/com/questhelper/panel/QuestOverviewPanel.java +++ b/src/main/java/com/questhelper/panel/QuestOverviewPanel.java @@ -40,6 +40,7 @@ import java.awt.event.ItemEvent; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.concurrent.CopyOnWriteArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -95,7 +96,7 @@ public class QuestOverviewPanel extends JPanel private final JButton collapseBtn = new JButton(); - private final List questStepPanelList = Collections.synchronizedList(new ArrayList<>()); + private final List questStepPanelList = new CopyOnWriteArrayList<>(); public QuestOverviewPanel(QuestHelperPlugin questHelperPlugin, QuestManager questManager) {