[MAGNOLIA-6725] DefaultMessageBundlesLoader is always re-instantiated in order to reflect changes in message bundle Created: 20/Jul/16  Updated: 05/Apr/17  Resolved: 10/Feb/17

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

Type: Improvement Priority: Neutral
Reporter: Philip Mundt Assignee: Philip Mundt
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Cloners
is cloned by MAGNOLIA-7003 CLONE - DefaultMessageBundlesLoader i... Open
Relates
relates to MAGNOLIA-6724 TranslationService should not throw P... Closed
relates to MAGNOLIA-6927 TempFileSystemResourceOrigin might be... Open
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)
Date of First Response:
Sprint: Basel 79, Basel 80, Basel 83
Story Points: 5

 Description   

While QAing MAGNOLIA-6724 & MGNLGROOVY-143 we found that info.magnolia.i18nsystem.DefaultMessageBundlesLoader#logDuplicates and its verbose output in the log was printed twice – once upon component initialisation and once when calling info.magnolia.i18nsystem.TranslationServiceImpl#reloadMessageBundles.

The reason is that info.magnolia.i18nsystem.TranslationServiceImpl#setupMessageBundles creates a new instance of DefaultMessageBundlesLoader for each call, therefore omitting the component definition in META-INF/magnolia/i18n.xml of the i18n module.

It would be desirable to use

protected DefaultMessageBundlesLoader setupMessageBundles() {
    return componentProvider.getComponent(DefaultMessageBundlesLoader.class);
}

instead of

protected DefaultMessageBundlesLoader setupMessageBundles() {
    return componentProvider.newInstance(DefaultMessageBundlesLoader.class, resourceOrigin);
}

in order to only maintain one component and therefore preventing potential memory leaks.

However this will prevent for any changes in message properties files to be reflected in the translation service during runtime. Possible workaround could be to add the possibility to reload message property files in DefaultMessageBundlesLoader or make it aware of changes in origins (info.magnolia.resourceloader.ResourceOriginChange). Ideally we move registration of the event handler for ModulesStartedEvent to the component DefaultMessageBundlesLoader.

We should investigate and also find out why the new instance call was added in the first place and what impact above change could have.



 Comments   
Comment by Ilgun Ilgun [ 19/Aug/16 ]

How ?

Comment by Roman Kovařík [ 23/Jan/17 ]

https://git.magnolia-cms.com/projects/PLATFORM/repos/main/pull-requests/253/overview?commentId=12757

Generated at Mon Feb 12 04:17:15 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.