db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1750214 - /db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/DerbyObservable.java
Date Sat, 25 Jun 2016 17:09:27 GMT
Author: rhillegas
Date: Sat Jun 25 17:09:26 2016
New Revision: 1750214

URL: http://svn.apache.org/viewvc?rev=1750214&view=rev
Log:
DERBY-6891: Improve the synchronization behavior of DerbyObservable; commit derby-6891-01-ab-synchronizeMethods.diff.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/DerbyObservable.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/DerbyObservable.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/DerbyObservable.java?rev=1750214&r1=1750213&r2=1750214&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/DerbyObservable.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/services/monitor/DerbyObservable.java
Sat Jun 25 17:09:26 2016
@@ -21,7 +21,7 @@
 
 package org.apache.derby.iapi.services.monitor;
 
-import java.util.Vector;
+import java.util.ArrayList;
 
 /**
  * <p>
@@ -39,7 +39,7 @@ public class DerbyObservable
     //////////////////////////////////////////////////////////////////////
   
     private boolean _hasChanged = false;
-    private Vector<DerbyObserver> _observers;
+    private ArrayList<DerbyObserver> _observers;
 
     //////////////////////////////////////////////////////////////////////
     //
@@ -48,7 +48,7 @@ public class DerbyObservable
     //////////////////////////////////////////////////////////////////////
   
     /** No-arg constructor */
-    public DerbyObservable() { _observers = new Vector<DerbyObserver>(); }
+    public DerbyObservable() { _observers = new ArrayList<DerbyObserver>(); }
 
     //////////////////////////////////////////////////////////////////////
     //
@@ -63,11 +63,11 @@ public class DerbyObservable
      *
      * @throws IllegalArgumentException If the argument is bad (e.g., null)
      */
-    public void addObserver(DerbyObserver observer)
+    public synchronized void addObserver(DerbyObserver observer)
     {
       if (observer == null) { throw new IllegalArgumentException("Null arguments not allowed.");
}
 
-      if (!_observers.contains(observer)) { _observers.addElement(observer); }
+      if (!_observers.contains(observer)) { _observers.add(observer); }
     }
 
     /**
@@ -75,14 +75,14 @@ public class DerbyObservable
      *
      * @return The number of watchers
      */
-    public int countObservers() { return _observers.size(); }
+    public synchronized int countObservers() { return _observers.size(); }
 
     /**
      * Remove a specific observer from the list of watchers. Null is ignored.
      *
      * @param observer The observer to remove.
      */
-    public void deleteObserver(DerbyObserver observer) { _observers.removeElement(observer);
}
+    public synchronized void deleteObserver(DerbyObserver observer) { _observers.remove(observer);
}
 
     /**
      * This method is equivalent to notifyObservers(null);
@@ -129,6 +129,6 @@ public class DerbyObservable
      * then the notifyObservers() will wake up the observers which are
      * watching this object.
      */
-    protected void setChanged() { _hasChanged = true; }
+    protected synchronized void setChanged() { _hasChanged = true; }
   
 }



Mime
View raw message