AEM Injector for CQ i18n fails in non-script context

Description

There is another issue with the injection of the I18n object, when it is injected in models adapted for example from the Request of the Post Servlet. In this case the SlingBindings attribute is not set, since no script resolving is involved. In this case the original request is used, which is the instance of the org.apache.sling.engine.impl.SlingHttpServletRequestImpl3 class. This instance returns the NullResourceBundle, which does not provide any i18n support.

the only workaround I came up with, was to use the resource for adaption instead of request, in this case the AemInjector uses the request from ModelsImplConfiguration service and everything works fine.

As a solution when injecting the I18n object, we might want to try the slingBindings request, then fallback to the one from ModelsImplConfiguration and only then try the original one.

Activity

Show:
Stefan Seifert
January 14, 2015, 11:09 AM

[master 25f22e3], version 1.1.1-SNAPSHOT

i've implemented a fix as you proposed by preferring the thread-local provided request in this case, although it is not a perfect solution.
please validate if it helps.

Fixed

Assignee

Unassigned

Reporter

Stefan Seifert

Labels

None

Components

Fix versions

Affects versions

Priority

Minor