Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Mutability of EventListenerGroup should be restricted to the bootstrap phase #5956

Sanne started this conversation in Design Proposals
Discussion options

The EventListenerGroup SPI is designed to allow changes to the event listeners, which is very handy as it's the core integration point for Hibernate Envers, Search, and other powerful tools such as Micrometer integration.

However this same SPI is also accessible after the SessionFactory has completed bootstrap, and we're allowing to mutate the set of listeners at any point in time; there are several issues with this:

  1. Correctness is hard to ensure as the set of listeners might get swapped at any point in time, with no atomicity requirements.
  2. It's not using correct visibility patterns, in fact there is no guarantee at this time that changes to the listeners after bootstrap will be applied to all processors soon or ever [I'm going to correct this right now with a trivial patch but the way I have to do this non-intrusively is not ideal, a design change would be best].
  3. It's not possible to implement an higher efficiency version of the listeners system; in fact this is how I noticed, as some issues have been identified here and I was attempting to design an alternative.

Furthermore, the current SPI is defining both the integration contract with external libraries and also defining the internal contract to actually activate such listeners; I'm suggesting to maintain the current SPI for external integrations (it seems adequate for such purposes) but disallow changes after SessionFactory has been created.

We would then introduce a separate contract for internal iteration; this keeps the public SPI cleaner from internal needs and would also allow us more flexibility with future changes. I do intend such internal contract to require the set of listeners be "cast in stone" for the life of the SessionFactory though as that would keep things simpler, prevent tricky issues and allow for much higher efficiency (my POC shows there's dozens of simplifications we could do in such case).

Unfortunately such a change can't be done right now at short notice, as several such libraries would need to ensure they register their custom listeners during an earlier phase.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant
Morty Proxy This is a proxified and sanitized view of the page, visit original site.