Skip to content

Commit

Permalink
Fix race condition in WorkbenchPluginTest #1891
Browse files Browse the repository at this point in the history
Test test case testGetImageRegistryFromAdditionalDisplay() in
org.eclipse.ui.tests.api.WorkbenchPluginTest randomly fails because of a
race condition. A display is initialized in another thread, but the
initialization logic may access the value before it has actually been
set by the other thread. This is fixed by reordering the instructions.

Fixes #1891
  • Loading branch information
HeikoKlare committed May 22, 2024
1 parent 30bc1dc commit af7cdc3
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ private Display initializeDisplayInOtherThread() {
TestBarrier2 displayCreationBarrier = new TestBarrier2();
new Thread(() -> {
Display display = new Display();
displayCreationBarrier.setStatus(TestBarrier2.STATUS_DONE);
displayReference.set(display);
displayCreationBarrier.setStatus(TestBarrier2.STATUS_DONE);
while (!display.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
Expand Down

0 comments on commit af7cdc3

Please sign in to comment.