geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject cvs commit: incubator-geronimo/modules/timer/src/java/org/apache/geronimo/timer/vm VMWorkerPersistence.java
Date Wed, 21 Jul 2004 01:39:08 GMT
gdamour     2004/07/20 18:39:08

  Modified:    modules/timer/src/java/org/apache/geronimo/timer/vm
                        VMWorkerPersistence.java
  Log:
  Synchronize the lookup otherwise it is possible to have a concurrent modification of the
Map.
  
  Revision  Changes    Path
  1.3       +7 -5      incubator-geronimo/modules/timer/src/java/org/apache/geronimo/timer/vm/VMWorkerPersistence.java
  
  Index: VMWorkerPersistence.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/timer/src/java/org/apache/geronimo/timer/vm/VMWorkerPersistence.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- VMWorkerPersistence.java	20 Jul 2004 23:36:53 -0000	1.2
  +++ VMWorkerPersistence.java	21 Jul 2004 01:39:08 -0000	1.3
  @@ -81,10 +81,12 @@
   
       public Collection getIdsByKey(String key, Object userId) throws PersistenceException
{
           Collection ids = new ArrayList();
  -        for (Iterator iterator = tasks.values().iterator(); iterator.hasNext();) {
  -            WorkInfo workInfo = (WorkInfo) iterator.next();
  -            if (key.equals(workInfo.getKey()) && (userId == null || userId.equals(workInfo.getUserId())))
{
  -                ids.add(new Long(workInfo.getId()));
  +        synchronized(tasks) {
  +            for (Iterator iterator = tasks.values().iterator(); iterator.hasNext();) {
  +                WorkInfo workInfo = (WorkInfo) iterator.next();
  +                if (key.equals(workInfo.getKey()) && (userId == null || userId.equals(workInfo.getUserId())))
{
  +                    ids.add(new Long(workInfo.getId()));
  +                }
               }
           }
           return ids;
  
  
  

Mime
View raw message