[
https://issues.apache.org/jira/browse/SLING-10371?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17343241#comment-17343241
]
Julian Sedding commented on SLING-10371:
----------------------------------------
Thanks for the pointer [~rombert]. However, I believe that this issue is about
a different aspect, namely about a re-entry situation of the caching {{Map}}
within the same thread. This causes the {{ConcurrentModificationException}} on
the {{HashMap}}, but works if that one is substituted with a
{{ConcurrenthashMap}}.
I have created [PR
#31|https://github.com/apache/sling-org-apache-sling-api/pull/31] to
illustrate. It's easier to express in code ;)
[~joerghoh] thanks a lot for the test case, that makes it very easy to validate
a fix! BTW: I noticed that your old code passed on Java 8 but failed on Java 11
(I haven't tried any other versions). Maybe a change in the {{HashMap}}
implementation?
> 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: 10m
> 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)