cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r601836 - /cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Date Thu, 06 Dec 2007 19:59:51 GMT
Author: vgritsenko
Date: Thu Dec  6 11:59:47 2007
New Revision: 601836

URL: http://svn.apache.org/viewvc?rev=601836&view=rev
Log:
better, more informative debug messages.
returned boolean value was not used, switching to void return value.

Modified:
    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/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=601836&r1=601835&r2=601836&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 11:59:47 2007
@@ -168,8 +168,9 @@
 
     protected boolean waitForLock(Object key) {
         if (transientStore != null) {
+            final String lockKey = PIPELOCK_PREFIX + key;
+
             // Get a lock object from the store
-            String lockKey = PIPELOCK_PREFIX + key;
             Object lock;
             synchronized (transientStore) {
                 lock = transientStore.get(lockKey);
@@ -177,20 +178,22 @@
 
             // Avoid deadlock with self (see JIRA COCOON-1985).
             if (lock != null && lock != Thread.currentThread()) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Waiting on Lock '" + lockKey + "'");
+                }
+
                 try {
-                    // become owner of monitor
                     synchronized (lock) {
                         lock.wait();
                     }
-                } catch (InterruptedException e) {
+
                     if (getLogger().isDebugEnabled()) {
-                        getLogger().debug("Interrupted waiting for other pipeline to finish
processing, retrying...", e);
+                        getLogger().debug("Notified on Lock '" + lockKey + "'");
                     }
-                    return false;
-                }
-                if (getLogger().isDebugEnabled()) {
-                    getLogger().debug("Other pipeline finished processing, retrying to get
cached response.");
+                } catch (InterruptedException e) {
+                    /* ignored */
                 }
+
                 return false;
             }
         }
@@ -199,75 +202,61 @@
     }
 
     /**
-     * makes the lock (instantiates a new object and puts it into the store)
+     * Makes the lock (instantiates a new object and puts it into the store)
      */
-    protected boolean generateLock(Object key) {
-        boolean succeeded = true;
-
+    protected void generateLock(Object key) {
         if (transientStore != null && key != null) {
-            String lockKey = PIPELOCK_PREFIX + key;
+            final String lockKey = PIPELOCK_PREFIX + key;
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Adding Lock '" + lockKey + "'");
+            }
 
             synchronized (transientStore) {
                 if (transientStore.containsKey(lockKey)) {
-                    succeeded = false;
                     if (getLogger().isDebugEnabled()) {
-                        getLogger().debug("Lock already present in the store!");
+                        getLogger().debug("Lock EXISTS: '" + lockKey + "'");
                     }
                 } else {
                     Object lock = Thread.currentThread();
                     try {
                         transientStore.store(lockKey, lock);
                     } catch (IOException e) {
-                        if (getLogger().isDebugEnabled()) {
-                            getLogger().debug("Could not put lock in the store!", e);
-                        }
-                        succeeded = false;
+                        /* should not happen */
                     }
                 }
             }
         }
-
-        return succeeded;
     }
 
     /**
-     * releases the lock (notifies it and removes it from the store)
+     * Releases the lock (notifies it and removes it from the store)
      */
-    protected boolean releaseLock(Object key) {
-        boolean succeeded = true;
-
+    protected void releaseLock(Object key) {
         if (transientStore != null && key != null) {
-            String lockKey = PIPELOCK_PREFIX + key;
+            final String lockKey = PIPELOCK_PREFIX + key;
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Releasing Lock '" + lockKey + "'");
+            }
 
             Object lock = null;
             synchronized (transientStore) {
                 if (!transientStore.containsKey(lockKey)) {
-                    succeeded = false;
                     if (getLogger().isDebugEnabled()) {
-                        getLogger().debug("Lock not present in the store!");
+                        getLogger().debug("Lock MISSING: '" + lockKey + "'");
                     }
                 } else {
-                    try {
-                        lock = transientStore.get(lockKey);
-                        transientStore.remove(lockKey);
-                    } catch (Exception e) {
-                        if (getLogger().isDebugEnabled()) {
-                            getLogger().debug("Could not get lock from the store!", e);
-                        }
-                        succeeded = false;
-                    }
+                    lock = transientStore.get(lockKey);
+                    transientStore.remove(lockKey);
                 }
             }
 
-            if (succeeded && lock != null) {
-                // become monitor owner
+            if (lock != null) {
+                // Notify everybody who's waiting
                 synchronized (lock) {
                     lock.notifyAll();
                 }
             }
         }
-
-        return succeeded;
     }
 
     /**



Mime
View raw message