Joerg Hoh created SLING-12988:
---------------------------------
Summary: 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.0
Reporter: Joerg Hoh
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)