[
https://issues.apache.org/jira/browse/SLING-7538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16404892#comment-16404892
]
Vlad Bailescu commented on SLING-7538:
--------------------------------------
[~kwin], all attributes included in the {{requestAttributes}} option are being
reset, even if they were present/overwritten or new. They are being collected
at
https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/master/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java#L78
and null values are kept for the new attributes (see
https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/master/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ExtensionUtils.java#L60)
so they get reset at
https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/master/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java#L111
However, we are intentionally not taking a full snapshot of existing request
attributes and resetting to that, so that we allow people to set their own
attributes in their code after the include (which they should also take care to
cleanup when needed).
> Request attributes not correctly reset after using data-sly-resource or
> data-sly-include with requestAttributes
> ---------------------------------------------------------------------------------------------------------------
>
> Key: SLING-7538
> URL: https://issues.apache.org/jira/browse/SLING-7538
> Project: Sling
> Issue Type: Bug
> Components: Scripting
> Affects Versions: Scripting HTL Engine 1.0.20
> Reporter: Konrad Windszus
> Assignee: Radu Cotescu
> Priority: Major
>
> The option {{requestAttributes}} introduced with SLING-5812 does not
> correctly reset the request attributes after the request dispatcher returned.
> The reason for that is that
> https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/3b50f91c4f600081f0585e50dfb775c4b2856b89/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/ResourceRuntimeExtension.java#L115
> does only reset those reset attributes which have been previously attached
> to the request. In fact also all attributes which have been added initially
> through the {{requestAttributes}} option need to be removed as well. If you
> add a new request attribute to the request this new request attribute will
> not be removed and would still be leveraged in a subsequent call to
> `data-sly-resource` based on the same request (even if that one doesn't even
> set an option {{requestAttributes}}).
> The same applies to
> https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/3b50f91c4f600081f0585e50dfb775c4b2856b89/src/main/java/org/apache/sling/scripting/sightly/impl/engine/extension/IncludeRuntimeExtension.java#L73.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)