[
https://issues.apache.org/jira/browse/SLING-12471?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Radu Cotescu reassigned SLING-12471:
------------------------------------
Assignee: Radu Cotescu
> DependencyResolver can return null values
> -----------------------------------------
>
> Key: SLING-12471
> URL: https://issues.apache.org/jira/browse/SLING-12471
> Project: Sling
> Issue Type: Improvement
> Components: HTL, Scripting
> Affects Versions: Scripting HTL Engine 1.4.24-1.4.0
> Reporter: Joerg Hoh
> Assignee: Radu Cotescu
> Priority: Critical
>
> With caching enabled, under concurrency the ScriptDependencyResolver.resolve
> can return null values.
> Context:
> [Github|https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/06194b90ac5316f8c44ccd95e46948a8aa440ed8/src/main/java/org/apache/sling/scripting/sightly/impl/utils/ScriptDependencyResolver.java#L122]
> # Multiple threads are trying to resolve the same {{scriptIdentifier}}
> # They all proceed to [line
> 133|https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/06194b90ac5316f8c44ccd95e46948a8aa440ed8/src/main/java/org/apache/sling/scripting/sightly/impl/utils/ScriptDependencyResolver.java#L136]
> because the resolutionCache is not yet populated.
> # One thread gets the writeLock, resolves the result, stores it back into the
> resolutionCache, and eventually releases the write lock.
> # now all the other threads waiting on line 133 lock on the writelock
> one-by-one; and when checking the resolutionCache on [line
> 136|https://github.com/apache/sling-org-apache-sling-scripting-sightly/blob/06194b90ac5316f8c44ccd95e46948a8aa440ed8/src/main/java/org/apache/sling/scripting/sightly/impl/utils/ScriptDependencyResolver.java#L136],
> the resolutionCache is already populated; and then they just release the
> writelock and proceed. But during this time {{result}} is never read from the
> resolutionCache, so it's still {{null}} and returned as such.
> This normally happens immediately after startup, when the resolutionCache is
> still empty.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)