incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r960613 - in /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl: AbstractRepositoryEventHandler.java JobEventHandler.java TimedJobHandler.java
Date Mon, 05 Jul 2010 14:53:18 GMT
Author: cziegeler
Date: Mon Jul  5 14:53:17 2010
New Revision: 960613

URL: http://svn.apache.org/viewvc?rev=960613&view=rev
Log:
SLING-1581 : Concurrent session access in event handlers

Modified:
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
    sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java?rev=960613&r1=960612&r2=960613&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
Mon Jul  5 14:53:17 2010
@@ -76,6 +76,9 @@ public abstract class AbstractRepository
     /** The repository session to write into the repository. */
     protected Session writerSession;
 
+    /** Sync lock */
+    protected final Object writeLock = new Object();
+
     /** The path in the repository. */
     protected String repositoryPath;
 
@@ -214,14 +217,16 @@ public abstract class AbstractRepository
      */
     protected void stopWriterSession() {
         if ( this.writerSession != null ) {
-            try {
-                this.writerSession.getWorkspace().getObservationManager().removeEventListener(this);
-            } catch (RepositoryException e) {
-                // we just ignore it
-                this.logger.warn("Unable to remove event listener.", e);
+            synchronized ( this.writeLock ) {
+                try {
+                    this.writerSession.getWorkspace().getObservationManager().removeEventListener(this);
+                } catch (RepositoryException e) {
+                    // we just ignore it
+                    this.logger.warn("Unable to remove event listener.", e);
+                }
+                this.writerSession.logout();
+                this.writerSession = null;
             }
-            this.writerSession.logout();
-            this.writerSession = null;
         }
     }
 

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=960613&r1=960612&r2=960613&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
Mon Jul  5 14:53:17 2010
@@ -180,9 +180,6 @@ public class JobEventHandler
     public static volatile ThreadPool JOB_THREAD_POOL;
 
     /** Sync lock */
-    private final Object writeLock = new Object();
-
-    /** Sync lock */
     private final Object backgroundLock = new Object();
 
     /** Number of parallel jobs for the main queue. */

Modified: sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java?rev=960613&r1=960612&r2=960613&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
(original)
+++ sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/TimedJobHandler.java
Mon Jul  5 14:53:17 2010
@@ -91,9 +91,6 @@ public class TimedJobHandler
     /** Unloaded events. */
     protected Set<String>unloadedEvents = new HashSet<String>();
 
-    /** Sync lock */
-    private final Object writeLock = new Object();
-
     /**
      * @see org.apache.sling.event.impl.AbstractRepositoryEventHandler#startWriterSession()
      */



Mime
View raw message