changeset 6385:63431cee20ce

RT-36060 FXCollections.synchronized* wrappers do not have synchronized access to listeners
author Martin Sladecek <martin.sladecek@oracle.com>
date Fri, 28 Feb 2014 14:02:04 +0100
parents 29bfa7536f04
children 3de40ad882c4
files modules/base/src/main/java/javafx/collections/FXCollections.java
diffstat 1 files changed, 36 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/modules/base/src/main/java/javafx/collections/FXCollections.java	Thu Feb 27 16:56:48 2014 -0800
+++ b/modules/base/src/main/java/javafx/collections/FXCollections.java	Fri Feb 28 14:02:04 2014 +0100
@@ -982,11 +982,6 @@
             this.mutex = mutex;
         }
 
-        SynchronizedList(List<T> seq) {
-            this (seq, new Object());
-        }
-
-
         @Override
         public int size() {
             synchronized(mutex) {
@@ -1233,22 +1228,30 @@
 
         @Override
         public final void addListener(InvalidationListener listener) {
-            helper = ListListenerHelper.addListener(helper, listener);
+            synchronized (mutex) {
+                helper = ListListenerHelper.addListener(helper, listener);
+            }
         }
         
         @Override
         public final void removeListener(InvalidationListener listener) {
-            helper = ListListenerHelper.removeListener(helper, listener);
+            synchronized (mutex) {
+                helper = ListListenerHelper.removeListener(helper, listener);
+            }
         }
         
         @Override
         public void addListener(ListChangeListener<? super T> listener) {
-            helper = ListListenerHelper.addListener(helper, listener);
+            synchronized (mutex) {
+                helper = ListListenerHelper.addListener(helper, listener);
+            }
         }
 
         @Override
         public void removeListener(ListChangeListener<? super T> listener) {
-            helper = ListListenerHelper.removeListener(helper, listener);
+            synchronized (mutex) {
+                helper = ListListenerHelper.removeListener(helper, listener);
+            }
         }
 
 
@@ -1871,21 +1874,29 @@
 
         @Override
         public void addListener(InvalidationListener listener) {
-            listenerHelper = SetListenerHelper.addListener(listenerHelper, listener);
+            synchronized (mutex) {
+                listenerHelper = SetListenerHelper.addListener(listenerHelper, listener);
+            }
         }
 
         @Override
         public void removeListener(InvalidationListener listener) {
-            listenerHelper = SetListenerHelper.removeListener(listenerHelper, listener);
+            synchronized (mutex) {
+                listenerHelper = SetListenerHelper.removeListener(listenerHelper, listener);
+            }
         }
         @Override
         public void addListener(SetChangeListener<? super E> listener) {
-            listenerHelper = SetListenerHelper.addListener(listenerHelper, listener);
+            synchronized (mutex) {
+                listenerHelper = SetListenerHelper.addListener(listenerHelper, listener);
+            }
         }
 
         @Override
         public void removeListener(SetChangeListener<? super E> listener) {
-            listenerHelper = SetListenerHelper.removeListener(listenerHelper, listener);
+            synchronized (mutex) {
+                listenerHelper = SetListenerHelper.removeListener(listenerHelper, listener);
+            }
         }
     }
 
@@ -2757,23 +2768,30 @@
 
         @Override
         public void addListener(InvalidationListener listener) {
-            listenerHelper = MapListenerHelper.addListener(listenerHelper, listener);
-
+            synchronized (mutex) {
+                listenerHelper = MapListenerHelper.addListener(listenerHelper, listener);
+            }
         }
 
         @Override
         public void removeListener(InvalidationListener listener) {
-            listenerHelper = MapListenerHelper.removeListener(listenerHelper, listener);
+            synchronized (mutex) {
+                listenerHelper = MapListenerHelper.removeListener(listenerHelper, listener);
+            }
         }
 
         @Override
         public void addListener(MapChangeListener<? super K, ? super V> listener) {
-            listenerHelper = MapListenerHelper.addListener(listenerHelper, listener);
+            synchronized (mutex) {
+                listenerHelper = MapListenerHelper.addListener(listenerHelper, listener);
+            }
         }
 
         @Override
         public void removeListener(MapChangeListener<? super K, ? super V> listener) {
-            listenerHelper = MapListenerHelper.removeListener(listenerHelper, listener);
+            synchronized (mutex) {
+                listenerHelper = MapListenerHelper.removeListener(listenerHelper, listener);
+            }
         }
 
     }