Vadim Gritsenko wrote:

>>From: Chris Newland [mailto:[EMAIL PROTECTED]]
>>
>>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: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to