Skip to content

Commit

Permalink
Fix possible race condition when reading noMoreDrivers
Browse files Browse the repository at this point in the history
The accessor noMoreDrivers is not synchronized (visibility is ensured by
the fact that noMoreDrivers is volatile). With current logic it was
possible to observe noMoreDrivers flag set to true while
DriverFactory.noMoreDrivers() was stil in progress and not all
OperatorFactory.noMoreOperators() methods completed.
  • Loading branch information
losipiuk committed Feb 12, 2024
1 parent 3fc0988 commit a7b90cd
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public synchronized void noMoreDrivers()
if (noMoreDrivers) {
return;
}
noMoreDrivers = true;
for (OperatorFactory operatorFactory : operatorFactories) {
operatorFactory.noMoreOperators();
}
noMoreDrivers = true;
}

// no need to synchronize when just checking the boolean flag
Expand Down

0 comments on commit a7b90cd

Please sign in to comment.