[
https://issues.apache.org/jira/browse/SLING-5277?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15081843#comment-15081843
]
Alexander Klimetschek commented on SLING-5277:
----------------------------------------------
To fix the DESTROY handling, we can just call
{{this.perThreadScriptResolver.remove()}} without the {{get()}} beforehand and
the not null check.
However, how do we close the per script resource resolver then, in case it was
created? {{ThreadLocal.remove()}} doesn't return the removed object. It seems
we have to do the {{ThreadLocal.get() & initialValue()}} logic ourselves
(again), inside {{getScriptResourceResolver}} using {{ThreadLocal.set()}}, so
that {{ThreadLocal.get()}} will return null if no resolver was set for the
current thread.
> Performance: per thread script resolver (admin session) is always created
> even if cache is hit
> ----------------------------------------------------------------------------------------------
>
> Key: SLING-5277
> URL: https://issues.apache.org/jira/browse/SLING-5277
> Project: Sling
> Issue Type: Bug
> Components: Servlets
> Reporter: Alexander Klimetschek
> Attachments: SLING-5277.patch
>
>
> Since SLING-3441, for every request, a new admin / privileged session is
> [created in the
> SlingServletResolver|https://github.com/apache/sling/blob/trunk/bundles/servlets/resolver/src/main/java/org/apache/sling/servlets/resolver/internal/SlingServletResolver.java#L532].
> It is created before the script/servlet cache is checked, so in most cases
> when the cache is hit it is never used, but the cost of creating an extra
> session (which can vary, especially with concurrent traffic) is incurred.
> The per thread script resolver can be created lazily instead of directly in
> the event to avoid this.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)