[MAGNOLIA-3860] CacheModuleLifecycleListener references are not deleted on cache module restart Created: 17/Oct/11  Updated: 13/Jun/13  Resolved: 13/Jun/13

Status: Closed
Project: Magnolia
Component/s: cache
Affects Version/s: 4.4.4
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Stefan Baur Assignee: Unassigned
Resolution: Not an issue Votes: 0
Labels: cache
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Visible to:
Daniel Kummer, Maribel Dapeton

 Description   

I have a class listening to the cache module startup event like:

CacheModule.getInstance().register(new CacheModuleLifecycleListener() {
public void onCacheModuleStart()

{ doStuff(); }

});

If a cache module reload is triggered (by changing content in the cache config), doStuff() will be called twice, and after again triggering a reload, doStuff() will be called three times.

I could work around this by overriding hashCode() and equals() in my CacheModuleLifecycleListener, but thought this could be fixed anyway.

Will it need a reset of the listeners Map in info.magnolia.module.cache.CacheModule#stop ?

Regards,
Stefan



 Comments   
Comment by Tobias Mattsson [ 01/Dec/11 ]

The fix does not really fix the problem, its still possible to register the listener multiple times. They will though be thrown away when the module is stopped. Since the restart of a module is stop-then-start this effectively means that all listeners are forgotten on restart, therefore the reload notification mechanism is broken, no notifications are given.

Comment by Stefan Baur [ 02/Dec/11 ]

Hello. I don't understand why this is no issue. If I want to execute code when the cache module starts, what would you expect me to do?
doStuff() just gets executed multiple times, and there is no way to check if the cache module already has my CacheModuleLifecycleListener registered or not.

Comment by Magnolia International [ 02/Dec/11 ]

There was indeed no reason to close this, the issue still exists.

Comment by Stefan Baur [ 18/Jan/13 ]

I think the problem here was, that I registered the listener during cache module initialization (in a cache voter). So this ended up in a special case, where the registration happened all the time when the cache module was reloaded.

If I remember correctly, a static final instance of my CacheModuleLifecycleListener would have worked, instead of the anonymous one used above.

--> You can indeed close it as Not an issue. (Sorry Tobias for raising it again...)

Generated at Mon Feb 12 03:50:22 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.