Return-Path: Delivered-To: apmail-sling-commits-archive@www.apache.org Received: (qmail 92013 invoked from network); 11 Dec 2009 17:23:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Dec 2009 17:23:28 -0000 Received: (qmail 8769 invoked by uid 500); 11 Dec 2009 17:23:28 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 8715 invoked by uid 500); 11 Dec 2009 17:23:28 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 8706 invoked by uid 99); 11 Dec 2009 17:23:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Dec 2009 17:23:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Dec 2009 17:23:26 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2E6D323889DA; Fri, 11 Dec 2009 17:23:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r889712 - in /sling/trunk/bundles/extensions/event: pom.xml src/main/java/org/apache/sling/event/impl/JobEventHandler.java Date: Fri, 11 Dec 2009 17:23:05 -0000 To: commits@sling.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091211172305.2E6D323889DA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: cziegeler Date: Fri Dec 11 17:23:04 2009 New Revision: 889712 URL: http://svn.apache.org/viewvc?rev=889712&view=rev Log: SLING-1235 : Access to writer session is not synchronized Modified: sling/trunk/bundles/extensions/event/pom.xml sling/trunk/bundles/extensions/event/src/main/java/org/apache/sling/event/impl/JobEventHandler.java Modified: sling/trunk/bundles/extensions/event/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/pom.xml?rev=889712&r1=889711&r2=889712&view=diff ============================================================================== --- sling/trunk/bundles/extensions/event/pom.xml (original) +++ sling/trunk/bundles/extensions/event/pom.xml Fri Dec 11 17:23:04 2009 @@ -55,7 +55,7 @@ - org.apache.sling.event;version=${pom.version} + org.apache.sling.event;version=2.0.6 org.apache.sling.event.impl, 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=889712&r1=889711&r2=889712&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 Fri Dec 11 17:23:04 2009 @@ -355,12 +355,6 @@ } if ( event != null && this.running ) { logger.debug("Persisting job {}", event); - try { - this.writerSession.refresh(false); - } catch (RepositoryException re) { - // we just ignore this - this.ignoreException(re); - } final EventInfo info = new EventInfo(); info.event = event; final String jobId = (String)event.getProperty(EventUtil.PROPERTY_JOB_ID); @@ -371,48 +365,58 @@ // need locking if ( jobId == null ) { try { - final Node eventNode = this.writeEvent(event, nodePath); - info.nodePath = eventNode.getPath(); + synchronized ( this.writeLock ) { + final Node eventNode = this.writeEvent(event, nodePath); + info.nodePath = eventNode.getPath(); + } } catch (RepositoryException re ) { // something went wrong, so let's log it this.logger.error("Exception during writing new job '" + EventUtil.toString(event) + "' to repository at " + nodePath, re); } } else { - try { - // let's first search for an existing node with the same id - final Node parentNode = this.ensureRepositoryPath(); - Node foundNode = null; - if ( parentNode.hasNode(nodePath) ) { - foundNode = parentNode.getNode(nodePath); - } - if ( foundNode != null ) { - // if the node is locked, someone else was quicker - // and we don't have to process this job - if ( !foundNode.isLocked() ) { - // node is already in repository, so if not finished we just use it - // otherwise it has already been processed - try { - if ( !foundNode.hasProperty(EventHelper.NODE_PROPERTY_FINISHED) ) { - info.nodePath = foundNode.getPath(); + synchronized ( this.writeLock ) { + try { + this.writerSession.refresh(false); + } catch (RepositoryException re) { + // we just ignore this + this.ignoreException(re); + } + try { + // let's first search for an existing node with the same id + final Node parentNode = this.ensureRepositoryPath(); + Node foundNode = null; + if ( parentNode.hasNode(nodePath) ) { + foundNode = parentNode.getNode(nodePath); + } + if ( foundNode != null ) { + // if the node is locked, someone else was quicker + // and we don't have to process this job + if ( !foundNode.isLocked() ) { + // node is already in repository, so if not finished we just use it + // otherwise it has already been processed + try { + if ( !foundNode.hasProperty(EventHelper.NODE_PROPERTY_FINISHED) ) { + info.nodePath = foundNode.getPath(); + } + } catch (RepositoryException re) { + // if anything goes wrong, it means that (hopefully) someone + // else is processing this node } - } catch (RepositoryException re) { - // if anything goes wrong, it means that (hopefully) someone - // else is processing this node + } + } else { + // We now write the event into the repository + try { + final Node eventNode = this.writeEvent(event, nodePath); + info.nodePath = eventNode.getPath(); + } catch (ItemExistsException iee) { + // someone else did already write this node in the meantime + // nothing to do for us } } - } else { - // We now write the event into the repository - try { - final Node eventNode = this.writeEvent(event, nodePath); - info.nodePath = eventNode.getPath(); - } catch (ItemExistsException iee) { - // someone else did already write this node in the meantime - // nothing to do for us - } + } catch (RepositoryException re ) { + // something went wrong, so let's log it + this.logger.error("Exception during writing new job '" + event + "' to repository at " + nodePath, re); } - } catch (RepositoryException re ) { - // something went wrong, so let's log it - this.logger.error("Exception during writing new job '" + event + "' to repository at " + nodePath, re); } } // if we were able to write the event into the repository