pranav created FINERACT-2822:
--------------------------------
Summary: Prevent concurrent modification of supported cache names
Key: FINERACT-2822
URL: https://issues.apache.org/jira/browse/FINERACT-2822
Project: Apache Fineract
Issue Type: Bug
Reporter: pranav
SpotBugs 4.9.3 reports a potential concurrency issue in
SpecifiedCacheSupportingCacheManager after the JDK upgrade from JDK 17 to JDK
25.
The supportedCacheNames field is a LinkedHashSet that can be accessed
concurrently.
setSupportedCaches() modifies the set while getCacheNames() exposes a
collection backed by the same set. Concurrent iteration and modification
can result in ConcurrentModificationException and unsafe concurrent access.
The implementation should synchronize access to supportedCacheNames and
return a snapshot from getCacheNames() so callers cannot iterate over the
internally mutable set while it is being modified.
A regression test should verify that concurrent reads and updates do not
throw an exception.
h3. Steps to reproduce
# Create a SpecifiedCachesSupportingCacheManager instance.
# Add initial supported cache names.
# Start one thread repeatedly calling getCacheNames() and iterating over
# Concurrently start another thread repeatedly calling setSupportedCaches()
# Concurrent iteration and modification can result in
ConcurrentModificationException
--
This message was sent by Atlassian Jira
(v8.20.10#820010)