jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marc Speck" <marcsp...@gmail.com>
Subject Re: Extending SimpleWebDavServlet
Date Mon, 29 Sep 2008 11:12:37 GMT
Very interesting, thanks for the feedback! Let me see whether I got it:

1. All statements below refer to Java 1.5.

2. fieldX = new SomeType(zzz)
- This is thread-safe if SomeType is immutable. An immutable object
  - unmodifiable state
  - all fields are final and all fields hold immutable objects
  - proper construction: "this" is not escaped in the constructor.
- LocatorFactoryImplEx is an immutable object

3. Construction and assigning different instances of LocatorFactoryImplEx()
to locatorFactory is allowed

4. Running Jackrabbit under Java 1.4 has got threading issues because of the
revised final as mentioned above.

5. > Actually, this internal field is the source of a potential data race:
> A runs up to the point, when it has constructed LocatorFactoryImplEx but
> not yet assigned the internal field. Thread A gets on hold relative to
> thread B. B runs through the getter and sees that locatorFactory is not
> null, fetches the object, access the uninitialized internal field and
voilĂ !
> We have a mess.
This is wrong for immutable objects like LocatorFactoryImplEx(). It only
applies to mutable objects.

Can I suggest to add a note in the doc that all those classes need to be
immutable? Next, I gonna learn why the mutable resourceConfig in
SimpleWebDavServlet.getResourceFactory() is fine for multiple threads...


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message