It is possible to cause a ConcurrentModificationException in the RequestContext because we synchronize it by using Collections.synchronizedMap(), which only synchronizes individual reads/writes. When making a RequestContext copy we must iterate over the collection, allowing other threads to interrupt it by modifying the map during the operation.
This fix synchronizes the whole copy operation as well. The default
mutex used for synchronizing in a SynchronizedMap is this, so
synchronizing on the map itself guards against modification.
It is possible to cause a
ConcurrentModificationException
in theRequestContext
because we synchronize it by usingCollections.synchronizedMap()
, which only synchronizes individual reads/writes. When making aRequestContext
copy we must iterate over the collection, allowing other threads to interrupt it by modifying the map during the operation.This fix synchronizes the whole copy operation as well. The default mutex used for synchronizing in a
SynchronizedMap
isthis
, so synchronizing on the map itself guards against modification.