You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2007/12/06 23:05:04 UTC

svn commit: r601871 - in /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl: pom.xml src/changes/changes.xml src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java

Author: vgritsenko
Date: Thu Dec  6 14:05:04 2007
New Revision: 601871

URL: http://svn.apache.org/viewvc?rev=601871&view=rev
Log:
      <action dev="vgritsenko" type="fix" fixes-bug="COCOON-1985">
        Use Spring's current request attributes as a pipeline lock object
        instead of current thread. Resolves deadlock when request is processed
        in multiple threads.
      </action>


Modified:
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/changes/changes.xml
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml?rev=601871&r1=601870&r2=601871&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/pom.xml Thu Dec  6 14:05:04 2007
@@ -115,6 +115,10 @@
       <artifactId>spring-core</artifactId>
     </dependency>   
     <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-web</artifactId>
+    </dependency>   
+    <dependency>
       <groupId>xml-apis</groupId>
       <artifactId>xml-apis</artifactId>
     </dependency>

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/changes/changes.xml?rev=601871&r1=601870&r2=601871&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/changes/changes.xml (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/changes/changes.xml Thu Dec  6 14:05:04 2007
@@ -17,15 +17,28 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<!--+
-    | Find usage details at http://maven.apache.org/plugins/maven-changes-plugin/usage.html
-    |
-    | @version $Id$
-    +-->
+
+<!--
+  - See http://maven.apache.org/plugins/maven-changes-plugin/usage.html
+  - $Id$
+  -->
 <document>
   <body>
-    <release version="1.0.0-M1-SNAPSHOT" date="2007-00-00" description="unreleased">  
-      
+    <release version="1.0.0" date="2008-00-00" description="unreleased">
+      <action dev="vgritsenko" type="fix" fixes-bug="COCOON-1985">
+        Use Spring's current request attributes as a pipeline lock object
+        instead of current thread. Resolves deadlock when request is processed
+        in multiple threads.
+      </action>
+    </release>
+
+    <release version="1.0.0-RC2" date="2007-10-12" description="released">
+    </release>
+
+    <release version="1.0.0-RC1" date="2007-06-27" description="released">
+    </release>
+
+    <release version="1.0.0-M1" date="2007-02-13" description="released">
     </release>
   </body>
 </document>

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java?rev=601871&r1=601870&r2=601871&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java Thu Dec  6 14:05:04 2007
@@ -16,15 +16,14 @@
  */
 package org.apache.cocoon.components.pipeline.impl;
 
-import org.apache.cocoon.ProcessingException;
-import org.apache.cocoon.caching.CacheableProcessingComponent;
-import org.apache.cocoon.caching.CachedResponse;
-import org.apache.cocoon.caching.CachingOutputStream;
-import org.apache.cocoon.caching.ComponentCacheKey;
-import org.apache.cocoon.caching.PipelineCacheKey;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.transformation.Transformer;
-import org.apache.cocoon.util.HashUtil;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
 
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameters;
@@ -34,16 +33,17 @@
 import org.apache.excalibur.source.impl.validity.DeferredValidity;
 import org.apache.excalibur.source.impl.validity.NOPValidity;
 import org.apache.excalibur.store.Store;
+import org.springframework.web.context.request.RequestContextHolder;
 
-import javax.servlet.http.HttpServletResponse;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheableProcessingComponent;
+import org.apache.cocoon.caching.CachedResponse;
+import org.apache.cocoon.caching.CachingOutputStream;
+import org.apache.cocoon.caching.ComponentCacheKey;
+import org.apache.cocoon.caching.PipelineCacheKey;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.transformation.Transformer;
+import org.apache.cocoon.util.HashUtil;
 
 /**
  * This is the base class for all caching pipeline implementations
@@ -166,6 +166,11 @@
         this.readerRole = role;
     }
 
+    /**
+     * Look up the lock object by key, and if present, wait till notified.
+     *
+     * @return false if able to find a lock and was notified
+     */
     protected boolean waitForLock(Object key) {
         if (transientStore != null) {
             final String lockKey = PIPELOCK_PREFIX + key;
@@ -177,7 +182,8 @@
             }
 
             // Avoid deadlock with self (see JIRA COCOON-1985).
-            if (lock != null && lock != Thread.currentThread()) {
+            Object current = RequestContextHolder.getRequestAttributes();
+            if (lock != null && lock != current) {
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Waiting on Lock '" + lockKey + "'");
                 }
@@ -217,7 +223,7 @@
                         getLogger().debug("Lock EXISTS: '" + lockKey + "'");
                     }
                 } else {
-                    Object lock = Thread.currentThread();
+                    Object lock = RequestContextHolder.getRequestAttributes();
                     try {
                         transientStore.store(lockKey, lock);
                     } catch (IOException e) {