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 2025/10/31 19:43:00 UTC

[jira] [Updated] (SLING-12988) Concurrent checks for a runmode can block under concurrency

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

Joerg Hoh updated SLING-12988:
------------------------------
    Affects Version/s: Settings 1.4.2
                           (was: Settings 1.4.0)

> Concurrent checks for a runmode can block under concurrency
> -----------------------------------------------------------
>
>                 Key: SLING-12988
>                 URL: https://issues.apache.org/jira/browse/SLING-12988
>             Project: Sling
>          Issue Type: Task
>    Affects Versions: Settings 1.4.2
>            Reporter: Joerg Hoh
>            Assignee: Joerg Hoh
>            Priority: Trivial
>
> We have a sling model like this:
> {noformat}
>     @PostConstruct
>     protected void init() {
>         Set<String> runmodes = slingSettingsService.getRunModes();
>         if (runmodes.contains(GlobalConstants.RUNMODE_PROD)) {
>             isProd = true;
>         }
>         if (runmodes.contains(GlobalConstants.RUNMODE_PUBLISH)) {
>             isPublish = true;
>         }
>         [checks for more runmodes]
> {noformat}
> if invoked under high concurrency, this can block on the .contains check, because the Set returned by {{SlingSettingsServiceImpl.getRunModes}} is a SynchronizedCollection.
> This is a rare condition (plus we also want to change the code to reduce the number of such checks), but we should definitely just return a UnmodifiabeCollection, it does not need to be a SynchronizedCollection (see the comment at https://github.com/apache/sling-org-apache-sling-settings/blob/e89534fcc34cae76fe97725567e5b03fbfc3800e/src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java#L229-L230)



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