Paul Rogers created DRILL-5676:
----------------------------------

             Summary: TestCountDownLatchInjection.latchInjected contains race 
conditions
                 Key: DRILL-5676
                 URL: https://issues.apache.org/jira/browse/DRILL-5676
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 1.10.0
            Reporter: Paul Rogers


Consider the unit test {{TestCountDownLatchInjection.latchInjected}}. This test 
sets up a multi-threaded test case to test a latch mechanism. But, the test 
code contains race conditions. The code first starts a bunch of threads that 
use the latch, then initializes the latch.

Proper logic would initialize the latch, then launch the threads.

As a result of the race condition, the test randomly fails. Developers spend 
much time tracking down each failure to be sure that it is just random. Let's 
just fix this test and be done with it.

Code:

{code}
    // Start the threads that will trigger the count downs on the latch
    (new ThreadCreator(dummyClass, trigger, threads, countingDownTime)).start();
    final long timeSpentWaiting;
    try {
      // Initialize the latch and wait for count downs
      timeSpentWaiting = dummyClass.initAndWait();
{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to