[ 
https://issues.apache.org/jira/browse/SLING-10371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17343808#comment-17343808
 ] 

Joerg Hoh commented on SLING-10371:
-----------------------------------

The 
[javadoc|https://docs.oracle.com/javase/8/docs/api/java/util/Map.html#computeIfAbsent-K-java.util.function.Function-]
 (Java8) does not make any assumption about concurrency, but that's different 
with [java 
11|https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ConcurrentHashMap.html#computeIfAbsent(K,java.util.function.Function)]:

_The entire method invocation is performed atomically, so the function is 
applied at most once per key. Some attempted update operations on this map by 
other threads may be blocked while computation is in progress, so the 
computation should be short and simple, and {color:red}must not attempt to 
update any other mappings of this map{color}._

I don't think that concurrency (as in parallel access via multiple threads) is 
a big concern, as most classes inheriting from {{SlingAdaptable}} are not 
thread-safe anyway.


> SlingAdaptable: ConcurrentModificationException on nested adaptTo() calls
> -------------------------------------------------------------------------
>
>                 Key: SLING-10371
>                 URL: https://issues.apache.org/jira/browse/SLING-10371
>             Project: Sling
>          Issue Type: Task
>          Components: API
>    Affects Versions: API 2.23.4
>            Reporter: Joerg Hoh
>            Assignee: Joerg Hoh
>            Priority: Major
>             Fix For: API 2.23.6
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> I introduced a regression with SLING-10327, that nested adaptTo() calls on 
> the same adaptable throw a ConcurrentModificationException.
> {noformat}
> java.util.ConcurrentModificationException
>       at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1134)
>       at 
> org.apache.sling.api.adapter.SlingAdaptable.adaptTo(SlingAdaptable.java:104)
>       at 
> org.apache.sling.resourceresolver.impl.ResourceResolverImpl.adaptTo(ResourceResolverImpl.java:636)
> {noformat}
> Reverting 
> https://github.com/apache/sling-org-apache-sling-api/commit/eeb8f84f92a2f1bbfad236ba9dca9c15c2e837f3
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to