jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Boston <...@tfd.co.uk>
Subject Re: Is an ObservationManager safe to use across threads?
Date Fri, 15 Oct 2010 10:17:16 GMT

On 15 Oct 2010, at 10:46, Vidar Ramdal wrote:

> Is this safe, or is the ObservationManager retrieved by
> session.getWorkspace().getObservationManager() tied to the session
> from which it was acquired?


In general its not safe since the session the observation manager was created with (which
must stay logged in for the ObservationManager to remain active) is stored internally and
used internally. There is one point where a check is made to ensure the same session is connected
to dispatches,

however, in the case of removeEventListener although some new objects are created that are
bound to the original session those objects are only used as keys to facilitate removal of
the listener so you should be Ok.

BTW,
Using a session inside an event listener will almost certainly lead to massive blocking and
potentially even deadlocks as the lower levels are protected (post 1.4 IIRC) to allow sessions
to be shared between multiple threads without doing permanent damage, so think of the onEvent
and the class/session that bound the on event as completely separate (and unfriendly) threads
that will conflict. ie, be very careful what you share inside and outside the onEvent method.

HTH
Ian
Mime
View raw message