You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "Arthur Naseef (Jira)" <ji...@apache.org> on 2022/01/19 17:15:00 UTC

[jira] [Commented] (ARIES-2065) ConcurrentModificationException at java.util.HashMap.computeIfAbsent

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

Arthur Naseef commented on ARIES-2065:
--------------------------------------

I have written 2 different ways of reliably catching the race condition, with the second forcing the HashMap's ConcurrentModificationException by modifying the mapping function passed to {{{}Map.computeIfAbsent(){}}}.  I can share this code if it helps.

A unit test to capture this case should be feasible.  However, understanding the timing of execution of the operation passed to {{fromOsgiRunnable()}} inside {{splitBy()}} has proven challenging for the time available.

The full stack trace of the ConcurrentModificationException runs through these:
{code:java}
org.apache.aries.component.dsl.internal.ServiceReferenceOSGi$DefaultServiceTrackerCustomizer.addingService
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding{code}
 

> ConcurrentModificationException at java.util.HashMap.computeIfAbsent
> --------------------------------------------------------------------
>
>                 Key: ARIES-2065
>                 URL: https://issues.apache.org/jira/browse/ARIES-2065
>             Project: Aries
>          Issue Type: Bug
>          Components: Component DSL
>            Reporter: Arthur Naseef
>            Priority: Major
>
> Using aries-jax-rs-whiteboard with resources from 2 different bundles, I hit the following.
> {code:java}
> java.util.ConcurrentModificationException
>    at java.base/java.util.HashMap.computeIfAbsent(Unknown Source)
>    at org.apache.aries.component.dsl.OSGi.lambda$null$79(OSGi.java:734)
>    at org.apache.aries.component.dsl.internal.JustOSGiImpl.lambda$new$2(JustOSGiImpl.java:47)
>    at org.apache.aries.component.dsl.internal.OSGiImpl.run(OSGiImpl.java:50){code}
> Debugging, this was tracked back to {{OSGi.splitBy()}} and it's use of {color:#172b4d}HashMap{color}.
> When this happens, the services fail to start up.  Since this is a race condition, it does not happen every time.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)