jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Felix Meschberger <fmesc...@gmail.com>
Subject Re: Extending SimpleWebDavServlet
Date Wed, 10 Sep 2008 21:58:24 GMT
Hi Marc,

Marc Speck schrieb:
> Ok, everybody seems to silently agree that there is no threading issue with
> this servlet method:
> public DavLocatorFactory getLocatorFactory() {
>     if (locatorFactory == null) {
>         locatorFactory = new LocatorFactoryImplEx(resourcePathPrefix);
>     }
>     return locatorFactory;
> }
> I just ask why this is thread safe. It is not called in servlet.init() or
> the like, isn't it?

I assume the default implementation has no thread issues actually
because the LocatorFactoryImplEx is a very simple class with a single
internal field set by the constructor.

In case of multi-threaded call to the getLocatorFactory method, multiple
instances of the LocatorFactoryImplEx class may be created of which only
a single one will ultimately remain assigned to the locatorFactory field.

If you overwrite this method and have a more complicated implementation
of the DavLocatorFactory interface, which you want to ensure, that only
a single instance is created, I suggest you implement synchronization in
your overwritten method.


View raw message