[ 
https://issues.apache.org/jira/browse/SLING-7538?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16404629#comment-16404629
 ] 

Konrad Windszus commented on SLING-7538:
----------------------------------------

bq. Only the attributes passed through the requestAttributes option are 
supposed to be removed / brought back to their initial state
This is unfortunately not the case. Only the attributes which have been 
overwritten are actually reset. 

Just think about the following HTL snippet
{code}
<sly data-sly-resource="${ 'child1' @ requestAttributes=some request 
attributes}" />
<sly data-sly-resource="${ 'child2' }" />
{code}

The request attributes being set for {{child1}} are bound to the current 
request and will also be used for {{child2}} because they are not correctly 
reset after the first {{data-sly-resource}}. That is a problem if child1 and 
child2 use the same underlying resource type and based on the request 
attributes they do render a bit differently. I would expect that then child2 
does not see any of the request attributes set for child1 which is right now 
not the case.

It is easy to spot the mistake in the code in 
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
 because only those request attributes which have been overwritten are actually 
being reset. But in fact all attributes should be reset (even new ones being 
introduced by {{requestAttributes}}).

> 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)

Reply via email to