Hi Julian, Am Mo., 27. Aug. 2018 um 13:51 Uhr schrieb Julian Sedding < jsedd...@gmail.com>:
> Hi Jörg > > I would argue that a new ResourceResolver for each "onEvent" call > would be advisable. Not only to avoid the problem you observe, but > also to avoid the risk of the session being used concurrently from > multiple threads. Not sure if JCR event hanlders may be called > concurrently though. > IIRC multiple handlers can run in parallel, but as observation must be handled in a strict serialized way, the sme handler is not running concurrently. Also creating new sessions / resource resolvers for each event can be quite some overhead, especially if a lot of events needs to be considered. > > The alternative, which doesn't guard against concurrent use, would be > to call refresh on the long-lived ResourceResolver, which you use to > register the JCR event listener, as the first thing in the "onEvent" > call. This will also refresh the internal > "resourceTypeResourceResolver" if it exists (it is created when > isResourceType() is called for the first time on a ResourceResolver, > and it is bound to that ResourceResolver's life-cycle). > > I guess that's the best way to handle this. I will recommend it. Thanks! Jörg -- Cheers, Jörg Hoh, http://cqdump.wordpress.com Twitter: @joerghoh