ConcurrentModificationException in OsgiClassLoader

Description

See attached log for a ConcurrentModificationException occuring, since org.hibernate.osgi.OsgiClassLoader makes non-thread-safe access to field "classLoaders".
The same applies for field "bundles" from my point of view.

Note: with a LinkedHashSet is in use, that retains insertion-order.
Fixed version should also retain insertion-order and be thread-safe.
There is no simple Concurrent*Set that fulfills this, so a blocking, easy solution is making the Set synchronized and synchronizing on it when iterating.

Note 2: I recommend to make fields "classCache" and "resourceCache" ConcurrentMaps and then also flag the ClassLoader as parallel-capable via call to java.lang.ClassLoader#registerAsParallelCapable

Environment

None

Assignee

Rico Neubauer

Reporter

Rico Neubauer

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure