You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2008/03/31 01:48:23 UTC
svn commit: r642843 - in /cocoon/branches/BRANCH_2_1_X:
src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
src/java/org/apache/cocoon/components/flow/WebContinuation.java status.xml
Author: joerg
Date: Sun Mar 30 16:48:21 2008
New Revision: 642843
URL: http://svn.apache.org/viewvc?rev=642843&view=rev
Log:
COCOON-2109: Fix clean up of continuations.
Modified:
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuation.java
cocoon/branches/BRANCH_2_1_X/status.xml
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java?rev=642843&r1=642842&r2=642843&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java Sun Mar 30 16:48:21 2008
@@ -90,13 +90,13 @@
/**
* How long does a continuation exist in memory since the last
- * access? The time is in miliseconds, and the default is 1 hour.
+ * access? The time is in milliseconds, and the default is 1 hour.
*/
protected int defaultTimeToLive;
/**
* Maintains the forest of <code>WebContinuation</code> trees.
- * This set is used only for debugging puroses by
+ * This set is used only for debugging purposes by
* {@link #displayAllContinuations()} method.
*/
protected Set forest = Collections.synchronizedSet(new HashSet());
@@ -147,6 +147,13 @@
}
/**
+ * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
+ }
+
+ /**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(final ServiceManager manager) throws ServiceException {
@@ -266,31 +273,46 @@
expirations.remove(parent);
}
}
-
/**
* @see org.apache.cocoon.components.flow.ContinuationsManager#lookupWebContinuation(java.lang.String, java.lang.String)
*/
public WebContinuation lookupWebContinuation(String id, String interpreterId) {
- // REVISIT: Is the following check needed to avoid threading issues:
- // return wk only if !(wk.hasExpired) ?
WebContinuationsHolder continuationsHolder = lookupWebContinuationsHolder(false);
if (continuationsHolder == null) {
return null;
}
WebContinuation kont = continuationsHolder.get(id);
- if(kont != null) {
- boolean interpreterMatches = kont.interpreterMatches(interpreterId);
- if (!interpreterMatches && getLogger().isWarnEnabled()) {
+ if (kont == null) {
+ return null;
+ }
+
+ if (kont.hasExpired()) {
+ removeContinuation(continuationsHolder, kont);
+ return null;
+ }
+
+ if (!kont.interpreterMatches(interpreterId)) {
+ if (getLogger().isWarnEnabled()) {
getLogger().warn("WK: Continuation (" + kont.getId()
+ ") lookup for wrong interpreter. Bound to: "
+ kont.getInterpreterId() + ", looked up for: "
+ interpreterId);
}
- return interpreterMatches || isContinuationSharingBugCompatible ? kont : null;
+
+ if (!isContinuationSharingBugCompatible) {
+ return null;
+ }
}
- return null;
+
+ // COCOON-2109: Sorting in the TreeSet happens on insert. So in order to re-sort the
+ // continuation has to be re-added.
+ expirations.remove(kont);
+ kont.updateLastAccessTime();
+ expirations.add(kont);
+
+ return kont;
}
/**
@@ -623,6 +645,7 @@
* continuation's expiration time.
*/
protected static class HolderAwareWebContinuation extends WebContinuation {
+
private WebContinuationsHolder continuationsHolder;
public HolderAwareWebContinuation(String id, Object continuation,
@@ -638,17 +661,6 @@
return continuationsHolder;
}
- //retain comparation logic from parent
- public int compareTo(Object other) {
- return super.compareTo(other);
- }
- }
-
- /**
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.context = context;
}
/**
Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuation.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuation.java?rev=642843&r1=642842&r2=642843&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuation.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuation.java Sun Mar 30 16:48:21 2008
@@ -201,7 +201,6 @@
* @return an <code>Object</code> value
*/
public Object getContinuation() {
- updateLastAccessTime();
return continuation;
}
@@ -218,7 +217,6 @@
*/
public WebContinuation getContinuation(int level) {
if (level <= 0) {
- updateLastAccessTime();
return this;
} else if (parentContinuation == null) {
return this;
Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?rev=642843&r1=642842&r2=642843&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Sun Mar 30 16:48:21 2008
@@ -182,6 +182,9 @@
<changes>
<release version="2.1.12" date="TBD">
+ <action dev="JH" type="fix" fixes-bug="COCOON-2109" due-to="Miguel Cuervo" due-to-email="miguel.cuervo@cgi.com">
+ Core: Fix clean up of continuations.
+ </action>
<action dev="JH" type="fix">
Javaflow: Minimize the data that's stored with ContinuationContext to limit the Continuation's memory footprint.
</action>
@@ -189,9 +192,8 @@
Forms: Widget Label is not Show/Hide when we change the widget state in ajax mode.
</action>
<action dev="VG" type="fix" fixes-bug="COCOON-1985">
- Use current HTTP request as a pipeline lock object instead of
- current thread. Resolves deadlock when request is processed
- in multiple threads.
+ Use current HTTP request as a pipeline lock object instead of current
+ thread. Resolves deadlock when request is processed in multiple threads.
</action>
<action dev="JH" type="fix">
Core: Close streams properly after copying Parts (MultipartParser). Allow to access InputStream of PartInMemory