Skip to content

Commit

Permalink
[corlib] Fixed test that failed intermittently
Browse files Browse the repository at this point in the history
There is a race condition in the test, the #2 Assert() can be reached before e1 is assigned if the thread
that handles e1 gets preempted by the scheduler (this is more likely on single-core systems).

Adding a sleep before checking the values fixes this for now.

Commit licensed under MIT/X11.
  • Loading branch information
akoeplinger committed Jun 19, 2014
1 parent 3e1d41a commit 559617d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mcs/class/corlib/Test/System/LazyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ public void ConcurrentInitialization ()
e3 = ex;
}

Thread.Sleep (1000);

Assert.AreSame (e1, e2, "#2");
Assert.AreSame (e1, e3, "#3");
}
Expand Down

0 comments on commit 559617d

Please sign in to comment.