You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2002/02/04 19:18:26 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/source DelayedRefreshSourceWrapper.java
sylvain 02/02/04 10:18:26
Modified: src/java/org/apache/cocoon Cocoon.java
src/java/org/apache/cocoon/components/source
DelayedRefreshSourceWrapper.java
Log:
Patch for concurrency issue causing a NPE in URLSource under high load
Revision Changes Path
1.11 +8 -5 xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java
Index: Cocoon.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Cocoon.java 4 Feb 2002 12:08:39 -0000 1.10
+++ Cocoon.java 4 Feb 2002 18:18:26 -0000 1.11
@@ -77,6 +77,7 @@
import org.apache.cocoon.components.parser.Parser;
import org.apache.cocoon.components.pipeline.EventPipeline;
import org.apache.cocoon.components.pipeline.StreamPipeline;
+import org.apache.cocoon.components.source.DelayedRefreshSourceWrapper;
import org.apache.cocoon.components.source.SourceHandler;
import org.apache.cocoon.components.source.URLSource;
import org.apache.cocoon.components.store.FilesystemStore;
@@ -103,7 +104,7 @@
* @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a> (Apache Software Foundation, Exoffice Technologies)
* @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
* @author <a href="mailto:leo.sutic@inspireinfrastructure.com">Leo Sutic</a>
- * @version CVS $Id: Cocoon.java,v 1.10 2002/02/04 12:08:39 cziegeler Exp $
+ * @version CVS $Id: Cocoon.java,v 1.11 2002/02/04 18:18:26 sylvain Exp $
*/
public class Cocoon
extends AbstractLoggable
@@ -182,9 +183,12 @@
this.classpath = (String)context.get(Constants.CONTEXT_CLASSPATH);
this.workDir = (File)context.get(Constants.CONTEXT_WORK_DIR);
try {
- this.configurationFile = new URLSource((URL)context.get(Constants.CONTEXT_CONFIG_URL),
- this.componentManager);
-
+ // FIXME : add a configuration option for the refresh delay.
+ // for now, hard-coded to 1 second.
+ this.configurationFile = new DelayedRefreshSourceWrapper(
+ new URLSource((URL)context.get(Constants.CONTEXT_CONFIG_URL), this.componentManager),
+ 1000L
+ );
} catch (IOException ioe) {
getLogger().error("Could not open configuration file.", ioe);
@@ -402,7 +406,6 @@
* @return a <code>boolean</code> value
*/
public boolean modifiedSince(long date) {
- this.configurationFile.refresh();
return date < this.configurationFile.getLastModified();
}
1.3 +6 -2 xml-cocoon2/src/java/org/apache/cocoon/components/source/DelayedRefreshSourceWrapper.java
Index: DelayedRefreshSourceWrapper.java
===================================================================
RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/DelayedRefreshSourceWrapper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DelayedRefreshSourceWrapper.java 4 Feb 2002 09:40:16 -0000 1.2
+++ DelayedRefreshSourceWrapper.java 4 Feb 2002 18:18:26 -0000 1.3
@@ -70,7 +70,7 @@
* <code>Source.getLastModified()</code> which can be a costly operation.
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version $Id: DelayedRefreshSourceWrapper.java,v 1.2 2002/02/04 09:40:16 cziegeler Exp $
+ * @version $Id: DelayedRefreshSourceWrapper.java,v 1.3 2002/02/04 18:18:26 sylvain Exp $
*/
public final class DelayedRefreshSourceWrapper implements Source, ModifiableSource, XMLizable {
@@ -102,6 +102,8 @@
* Get the last modification time for the wrapped <code>Source</code>. The
* age of the returned information is guaranteed to be lower than or equal to
* the delay specified in the constructor.
+ * <p>
+ * This method is also thread-safe, even if the underlying Source is not.
*
* @return the last modification time.
*/
@@ -119,8 +121,10 @@
/**
* Force the refresh of the wrapped <code>Source</code>, even if the refresh period
* isn't over, and starts a new period.
+ * <p>
+ * This method is thread-safe, even if the underlying Source is not.
*/
- public final void refresh() {
+ public synchronized final void refresh() {
this.nextCheckTime = System.currentTimeMillis() + this.delay;
// Refresh modifiable sources
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org