Use a threadsafe map in SearchAsyncActionTests #34506
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today
SearchAsyncActionTests#testFanOutAndCollect
uses a simpleHashMap
forthe
nodeToContextMap
variable, which is then accessed from multiple threadswithout, apparently, explicit synchronisation. This provides an explanation for
the test failure identified in #29242 in which
.toString()
returns"[]"
just before
.isEmpty
returnsfalse
, without any concurrent modifications.This change converts
nodeToContextMap
to anewConcurrentMap()
so that thiscannot occur. It also fixes a race condition in the detection of double-calling
the subsequent search phase.
This is a backport of #33700 to 5.6.
Relates #33700
Relates #29242