Author: bpapez
Date: Wed Jan  2 10:41:33 2008
New Revision: 19436

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19436&repname=
=3Djahia
Log:
JAHIA-2686: Problem with Latch not being released
- moved the avoidParallelProcessingOfSamePage into the try-catch bracket to=
 always release a latch, when it has been acquired by this thread

Modified:
    trunk/core/src/java/org/jahia/operations/valves/EngineValve.java

Modified: trunk/core/src/java/org/jahia/operations/valves/EngineValve.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/operations/valves/EngineValve.java&rev=3D19436&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/operations/valves/EngineValve.java (origi=
nal)
+++ trunk/core/src/java/org/jahia/operations/valves/EngineValve.java Wed Ja=
n  2 10:41:33 2008
@@ -147,19 +147,20 @@
         String engineName =3D processingContext.getEngine();
         Latch latch =3D null;
 =

-        if (state !=3D null
-                && state.isCacheable()
-                && !getGeneratorQueue().getNotCacheablePage().containsKey(
-                        state.getKey())) {
+        boolean semaphoreAcquired =3D false;
+        try {
+            if (state !=3D null
+                    && state.isCacheable()
+                    && !getGeneratorQueue().getNotCacheablePage().contains=
Key(
+                            state.getKey())) {
 =

-            latch =3D avoidParallelProcessingOfSamePage(state, processingC=
ontext);
+                latch =3D avoidParallelProcessingOfSamePage(state,
+                        processingContext);
 =

-            if (CacheReadValve.checkCache(processingContext))
-                return;
-        }
+                if (CacheReadValve.checkCache(processingContext))
+                    return;
+            }
 =

-        boolean semaphoreAcquired =3D false;
-        try {
             if (!getGeneratorQueue().getAvailableProcessings().attempt(
                     getGeneratorQueue().getPageGenerationWaitTime())) {
                 throw new JahiaServerOverloadedException(false, =

@@ -221,13 +222,15 @@
             }
             if (latch !=3D null) {
                 latch.release();
-            }
-            if (state !=3D null && state.getKey() !=3D null) {
-                Map generatingPages =3D getGeneratorQueue().getGeneratingP=
ages();
-                synchronized (generatingPages) {
-                    generatingPages.remove(state.getKey());
+                =

+                if (state !=3D null && state.getKey() !=3D null) {
+                    Map generatingPages =3D getGeneratorQueue().getGenerat=
ingPages();
+                    synchronized (generatingPages) {
+                        generatingPages.remove(state.getKey());
+                    }
                 }
             }
+
             ServicesRegistry.getInstance().getJahiaEventService()
                     .fireAggregatedEvents();
         }
@@ -248,19 +251,20 @@
                 mustWait =3D true;
             }
         }
-        try {
-            if (mustWait) {
+        if (mustWait) {
+            try {
                 if (!latch.attempt(getGeneratorQueue()
                         .getPageGenerationWaitTime())) {
-                    throw new JahiaServerOverloadedException(false,
-                            Jahia.getSettings().getSuggestedRetryTimeAfter=
Timeout());
+                    throw new JahiaServerOverloadedException(false, Jahia
+                            .getSettings().getSuggestedRetryTimeAfterTimeo=
ut());
                 }
+                latch =3D null;
+            } catch (InterruptedException ie) {
+                logger.debug("The waiting thread has been interrupted :", =
ie);
+                throw new PipelineException(ie);
+            } catch (Throwable je) {
+                throw new PipelineException(je);
             }
-        } catch (InterruptedException ie) {
-            logger.debug("The waiting thread has been interrupted :", ie);
-            throw new PipelineException(ie);
-        } catch (Throwable je) {
-            throw new PipelineException(je);
         }
         return latch;
     }

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to