Details
-
New Feature
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Sling Model:
@Model(adaptables = SlingHttpServletRequest.class, adapters = MySlingModel.class) class MySlingModel { @Inject public MySlingModel(@Self SlingHttpServletRequest req) { logger.log(req.getResourceBundle().getClass().getName()); } }
Calling code:
// req obtained via JSP/HTL final SlingHttpServletRequest myWrappedReq = new SlingHttpServletRequestWrapper(req) { @Override public ResourceBundle getResourceBundle() { return new MyCustomResourceBundle(); } }; final MySlingModel myModel = myWrappedReq.adaptTo(MySlingModel.class);
I would expect the log file to contain "MyCustomResourceBundle". Instead it contains "NullResourceBundle".
This is because the request is being "unwrapped" when doing the adaptTo() call: It keeps on delegating to the wrapped request. This should not have happened, i.e. how can we otherwise overwrite (parts of) requests and resources?
Attachments
Issue Links
- is related to
-
SLING-5668 Models: Leverage ServletRequestListener.requestDestroyed for calling DisposalCallback in case the model was created from a request
- Closed