You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2008/02/13 16:29:50 UTC

svn commit: r627472 - /incubator/sling/trunk/sling/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java

Author: cziegeler
Date: Wed Feb 13 07:29:47 2008
New Revision: 627472

URL: http://svn.apache.org/viewvc?rev=627472&view=rev
Log:
Fix for synchronization.

Modified:
    incubator/sling/trunk/sling/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java

Modified: incubator/sling/trunk/sling/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java?rev=627472&r1=627471&r2=627472&view=diff
==============================================================================
--- incubator/sling/trunk/sling/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java (original)
+++ incubator/sling/trunk/sling/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java Wed Feb 13 07:29:47 2008
@@ -82,6 +82,9 @@
     /** Unloaded jobs. */
     protected Set<String>unloadedJobs = new HashSet<String>();
 
+    /** List of deleted jobs. */
+    protected Set<String>deletedJobs = new HashSet<String>();
+
     /**
      * Activate this component.
      * @param context
@@ -523,24 +526,30 @@
 
                         // we are only interested in unlocks
                         if ( "jcr:lockOwner".equals(propertyName) ) {
-                            final Node eventNode = (Node) s.getItem(nodePath);
-                            if ( !eventNode.isLocked() ) {
-                                try {
-                                    final EventInfo info = new EventInfo();
-                                    info.event = this.readEvent(eventNode);
-                                    info.nodePath = nodePath;
+                            boolean doNotProcess = false;
+                            synchronized ( this.deletedJobs ) {
+                                doNotProcess = this.deletedJobs.remove(nodePath);
+                            }
+                            if ( !doNotProcess ) {
+                                final Node eventNode = (Node) s.getItem(nodePath);
+                                if ( !eventNode.isLocked() ) {
                                     try {
-                                        this.queue.put(info);
-                                    } catch (InterruptedException e) {
-                                        // we ignore this exception as this should never occur
-                                        this.ignoreException(e);
-                                    }
-                                } catch (ClassNotFoundException cnfe) {
-                                    // store path for lazy loading
-                                    synchronized ( this.unloadedJobs ) {
-                                        this.unloadedJobs.add(nodePath);
+                                        final EventInfo info = new EventInfo();
+                                        info.event = this.readEvent(eventNode);
+                                        info.nodePath = nodePath;
+                                        try {
+                                            this.queue.put(info);
+                                        } catch (InterruptedException e) {
+                                            // we ignore this exception as this should never occur
+                                            this.ignoreException(e);
+                                        }
+                                    } catch (ClassNotFoundException cnfe) {
+                                        // store path for lazy loading
+                                        synchronized ( this.unloadedJobs ) {
+                                            this.unloadedJobs.add(nodePath);
+                                        }
+                                        this.ignoreException(cnfe);
                                     }
-                                    this.ignoreException(cnfe);
                                 }
                             }
                         }
@@ -639,6 +648,9 @@
             final Node eventNode = (Node) this.backgroundSession.getItem(eventNodePath);
             try {
                 if ( !reschedule ) {
+                    synchronized ( this.deletedJobs ) {
+                        this.deletedJobs.add(eventNodePath);
+                    }
                     // unlock node
                     try {
                         eventNode.unlock();
@@ -663,6 +675,9 @@
                     }
                 }
                 if ( lockToken != null ) {
+                    synchronized ( this.deletedJobs ) {
+                        this.deletedJobs.add(eventNodePath);
+                    }
                     // unlock node
                     try {
                         eventNode.unlock();