incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r960616 - /sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
Date Mon, 05 Jul 2010 14:56:46 GMT
Author: cziegeler
Date: Mon Jul  5 14:56:45 2010
New Revision: 960616

URL: http://svn.apache.org/viewvc?rev=960616&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

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=960616&r1=960615&r2=960616&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:56:45 2010
@@ -125,7 +125,9 @@ public abstract class AbstractRepository
         this.threadPool.execute(new Runnable() {
             public void run() {
                 try {
-                    startWriterSession();
+                    synchronized ( writeLock ) {
+                        startWriterSession();
+                    }
                 } catch (RepositoryException e) {
                     // there is nothing we can do except log!
                     logger.error("Error during session starting.", e);
@@ -137,7 +139,9 @@ public abstract class AbstractRepository
                     logger.error("Writer thread stopped with exception: " + t.getMessage(),
t);
                     running = false;
                 }
-                stopWriterSession();
+                synchronized ( writeLock ) {
+                    stopWriterSession();
+                }
             }
         });
         this.threadPool.execute(new Runnable() {
@@ -217,16 +221,14 @@ public abstract class AbstractRepository
      */
     protected void stopWriterSession() {
         if ( this.writerSession != null ) {
-            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;
+            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;
         }
     }
 



Mime
View raw message