Skip to content

Commit

Permalink
HSEARCH-4078 Make log checking in ExpectedLog4jLog thread-safe
Browse files Browse the repository at this point in the history
Because we sometimes check logs that are added concurrently from
multiple threads, and if we aren't careful about being thread-safe, we
can miss some log events.

Signed-off-by: Yoann Rodière <[email protected]>
  • Loading branch information
yrodiere authored and wklaczynski committed Feb 14, 2021
1 parent 341f87a commit 0b8cee0
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public void appendFailure(Description description, String newline) {
}
}

void process(LogEvent event) {
// This must be synchronized to avoid problems when multiple threads issue log events concurrently
synchronized void process(LogEvent event) {
if ( expectation.getMaxExpectedCount() == null && expectation.getMinExpectedCount() <= count ) {
// We don't care about events anymore, expectations are met and it won't change
return;
Expand Down

0 comments on commit 0b8cee0

Please sign in to comment.