Author: cwiklik
Date: Fri May  2 16:51:10 2014
New Revision: 1591971

URL: http://svn.apache.org/r1591971
Log:
UIMA-3788 synchronized code in cancelTimerForCasOrPurge()

Modified:
    
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java

Modified: 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java?rev=1591971&r1=1591970&r2=1591971&view=diff
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java
 (original)
+++ 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/delegate/Delegate.java
 Fri May  2 16:51:10 2014
@@ -149,9 +149,11 @@ public abstract class Delegate {
   public  void cancelTimerForCasOrPurge(String casReferenceId) {
            if ( timer != null && timer.getTimerCasId() != null && 
timer.getTimerCasId().equals(casReferenceId)) {
              //System.out.println("\n\n\t Canceled Timer For 
CAS:"+casReferenceId+" and Restarting Timer for the next oldest CAS in the 
outstanding list\n\n");
-             cancelDelegateTimer();
-             //  Restart timer for the next older CAS in the oustanding list
-             restartTimerForOldestCasInOutstandingList();
+               synchronized( outstandingCasList ) {
+                         cancelDelegateTimer();
+                             //  Restart timer for the next older CAS in the 
oustanding list
+                             restartTimerForOldestCasInOutstandingList();
+               }
            } else {
              // Given CAS is not the oldest in outstanding list. Purge the CAS 
from both outstanding and
              // pending dispatch lists (if exists).
@@ -566,11 +568,14 @@ public abstract class Delegate {
     // Before removing the entry check if this is the oldest in the list. This 
will be
     // used to determine if we need to restart the delegate timer
     DelegateEntry oldestEntry = outstandingCasList.get(0);
-    boolean doStartDelegateTimer = false; //oldestEntry.equals(aDelegateEntry) 
&& getCasProcessTimeout() > 0;
+    boolean doStartDelegateTimer = false; 
     outstandingCasList.remove(aDelegateEntry);
     if ( getCasProcessTimeout() > 0 ) {
         if ( aDelegateEntry.usesDedicatedTimerThread) {
-               aDelegateEntry.getDelegateTimer().cancel();
+               synchronized( timerLock ) {
+                       aDelegateEntry.getDelegateTimer().cancel();
+               }
+               
         } else {
                doStartDelegateTimer = oldestEntry.equals(aDelegateEntry);
         }


Reply via email to