cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylvain.wal...@anyware-tech.com>
Subject Re: NPE in URLSource under high load
Date Mon, 04 Feb 2002 18:21:16 GMT
Vadim Gritsenko wrote:

>>From: Chris Newland [mailto:chris.newland@emorphia.com]
>>
>>Hi All,
>>
>>I'm encountering a null pointer exception in the
>>org.apache.cocoon.components.source.URLSource file when I run a stress
>>
>test
>
>>of my Cocoon 2 system:
>>
>>java.lang.NullPointerException
>>	at
>>
>org.apache.cocoon.components.source.URLSource.getInfos(URLSource.java:95
>)
>
>>	at
>>
>org.apache.cocoon.components.source.URLSource.getLastModified(URLSource.
>java
>
>>:110)
>>	at org.apache.cocoon.Cocoon.modifiedSince(Cocoon.java:376)
>>	at
>>
> 
><snip>
> 
>
>>Looking at the code makes me think this might be a
>>
>threading/synchronization
>
>>bug as IMHO 'this.connection' is null and should have thrown the NPE
>>
>on the
>
>>previous line.
>>
>
>It *is* threading bug. URLSource is not intended to be used by multiple
>threads simultaneously. However, Cocoon.java uses it exactly this way.
>
>
>>I'll do my best to trace the problem's origin but I'm out of the
>>
>country for
>
>>3 weeks as of tomorrow.
>>
>
>The quick (==bad performance) fix will be to surround call with
>synchronized:
>
>    public boolean modifiedSince(long date) {
>        synchronized(this.configurationFile) {
>            this.configurationFile.refresh();
>            return date < this.configurationFile.getLastModified();
>        }
>    }
>
>The better solution is to use ActiveMonitor. There was a discussion
>about it but I do not remember the results of it.
>
>Regards,
>Vadim
>
I made a quick update using DelayedSourceWrapper : getLastModified() is 
called only once per second (we should make it configurable) and is in a 
synchronized block.

This solves the concurrency issue at the price of one synchronized 
statement each second, which should be acceptable ;)

Sylvain

-- 
Sylvain Wallez
Anyware Technologies - http://www.anyware-tech.com




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message