From e05d6340d720057513bc46144acab8155f0f0218 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 13 May 2014 15:11:50 -0400 Subject: [PATCH] Fix up possible CME --- .../fml/common/eventhandler/ListenerList.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fml/src/main/java/cpw/mods/fml/common/eventhandler/ListenerList.java b/fml/src/main/java/cpw/mods/fml/common/eventhandler/ListenerList.java index ca9f6665a..1e0b91139 100644 --- a/fml/src/main/java/cpw/mods/fml/common/eventhandler/ListenerList.java +++ b/fml/src/main/java/cpw/mods/fml/common/eventhandler/ListenerList.java @@ -1,11 +1,12 @@ package cpw.mods.fml.common.eventhandler; import java.util.*; +import com.google.common.collect.ImmutableList; public class ListenerList { - private static ArrayList allLists = new ArrayList(); + private static ImmutableList allLists = ImmutableList.of(); private static int maxSize = 0; private ListenerList parent; @@ -13,15 +14,22 @@ public class ListenerList public ListenerList() { - allLists.add(this); + extendMasterList(this); resizeLists(maxSize); } public ListenerList(ListenerList parent) { - allLists.add(this); + this(); this.parent = parent; - resizeLists(maxSize); + } + + private synchronized static void extendMasterList(ListenerList inst) + { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.addAll(allLists); + builder.add(inst); + allLists = builder.build(); } public static void resize(int max)