changeset 7441:3bc2557efaad

RT-37836: ConcurrentModificationException in Cascading menu when running SceneBuilder Backed out changeset dfc51c66d790
author kcr
date Mon, 07 Jul 2014 10:52:14 -0700
parents 4e6634321740
children 7398ae52202d
files modules/graphics/src/main/java/com/sun/javafx/scene/KeyboardShortcutsHandler.java
diffstat 1 files changed, 1 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/scene/KeyboardShortcutsHandler.java	Mon Jul 07 07:19:32 2014 -0600
+++ b/modules/graphics/src/main/java/com/sun/javafx/scene/KeyboardShortcutsHandler.java	Mon Jul 07 10:52:14 2014 -0700
@@ -30,7 +30,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javafx.collections.ObservableList;
 import javafx.collections.ObservableMap;
@@ -95,12 +94,7 @@
 
     public ObservableMap<KeyCombination, Runnable> getAccelerators() {
         if (accelerators == null) {
-            // Note: accelerators are iterated and the Runnable is executed during the iteration.
-            // Since the Runnable can manipulate the accelerator list, we need to avoid ConcurrentModificationException in that case
-            // Copying the whole list on every traversal (which is on every key press/release) would be constly, so
-            // we use ConcurrentHashMap, which has iterators with weak consitency (it may or may not contain the changes done during the iteration)
-            // instead of fail-fast behavior. This does not mean accelerators is really concurrent though, the wrapper still does not support multi-threaded access.
-            accelerators = new ObservableMapWrapper<>(new ConcurrentHashMap<>());
+            accelerators = new ObservableMapWrapper<KeyCombination, Runnable>(new HashMap<KeyCombination, Runnable>());
         }
         return accelerators;
     }