[ 
https://issues.apache.org/jira/browse/SLING-13266?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joerg Hoh reassigned SLING-13266:
---------------------------------

    Assignee: Joerg Hoh

> BundledScriptTracker can race on shutdown
> -----------------------------------------
>
>                 Key: SLING-13266
>                 URL: https://issues.apache.org/jira/browse/SLING-13266
>             Project: Sling
>          Issue Type: Improvement
>          Components: Servlets
>    Affects Versions: Servlets Resolver 3.0.6
>            Reporter: Joerg Hoh
>            Assignee: Joerg Hoh
>            Priority: Minor
>
> h3. Summary
> {{BundledScriptTracker.deactivate()}} is not synchronized against 
> {{refreshDispatcher()}}, so the two can run concurrently and both write the 
> shared {{dispatchers}} {{AtomicReference}}.
> h3. Details
> {{refreshDispatcher()}} is {{synchronized}} and reads {{dispatchers}} (with a 
> {{null}} check for the deactivated state), then swaps in a new map at the 
> end. {{deactivate()}} sets {{dispatchers}} to {{null}} but takes no lock. If 
> {{deactivate()}} runs after a concurrent {{refreshDispatcher()}} has passed 
> its null check but before its final swap, the refresh re-publishes a 
> non-{{null}} map after shutdown. The {{DispatcherServlet}} registrations in 
> that map are then leaked (never unregistered), and the refresh may also call 
> {{register()}} with an already-nulled {{BundleContext}}.
> Shutdown-only, low severity.
> h3. Fix
> Make {{deactivate()}} {{synchronized}} so it cannot interleave with 
> {{refreshDispatcher()}}; a refresh then either completes before deactivation 
> or observes {{dispatchers == null}} and returns early.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to