Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-6725

DefaultMessageBundlesLoader is always re-instantiated in order to reflect changes in message bundle

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Neutral Neutral
    • 5.5.2
    • None
    • None
    • None
    • Basel 79, Basel 80, Basel 83
    • 5

      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.

        Acceptance criteria

              pmundt Philip Mundt
              pmundt Philip Mundt
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD