You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Joerg Hoh (Jira)" <ji...@apache.org> on 2026/06/24 12:21:00 UTC

[jira] [Assigned] (SLING-13170) Replace Timer-based delay in JobManagerConfiguration with injectable scheduler for testability

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

Joerg Hoh reassigned SLING-13170:
---------------------------------

    Assignee: Joerg Hoh

>  Replace Timer-based delay in JobManagerConfiguration with injectable scheduler for testability 
> ------------------------------------------------------------------------------------------------
>
>                 Key: SLING-13170
>                 URL: https://issues.apache.org/jira/browse/SLING-13170
>             Project: Sling
>          Issue Type: Improvement
>          Components: Event
>            Reporter: Daniel Iancu
>            Assignee: Joerg Hoh
>            Priority: Major
>
>  h3. Problem                                                                                                                                   
>                                                             
>   {{JobManagerConfiguration.startProcessing()}} uses {{java.util.Timer}} with a hardcoded wall-clock delay ({{backgroundLoadDelay}}) to debounce
>    listener notifications after topology changes. This has two problems:                                                                        
>                                                                                                                                                 
>   # *Tests depend on Thread.sleep() and real time* — {{testTopologyChange}} sleeps 4 seconds to verify no spurious events arrive, making it slow
>    and inherently flaky (the test was already flaky when {{backgroundLoadDelay}} was uninitialized at 0).
>   # *The Timer is fire-and-forget* — there's no way to cancel pending timers when the component deactivates, potentially leaking threads or     
>   firing after shutdown.                                                                                                                        
>    
>   h3. Proposed change                                                                                                                           
>                                                             
>   Replace the {{Timer}} in {{startProcessing()}} with a {{ScheduledExecutorService}} (or similar) that can be injected in tests. This would     
>   allow tests to use a controllable scheduler to:
>   * Advance time explicitly instead of sleeping                                                                                                 
>   * Verify debounce behavior deterministically              
>   * Eliminate the 4-second sleep in {{testTopologyChange}}
>                                                                                                                                                 
>   h3. Scope
>                                                                                                                                                 
>   {{JobManagerConfiguration.startProcessing()}} — the {{else}} branch for non-INIT topology events.



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