Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-2451

DefaultExecutorService invokeAny(Collection tasks, long timeout, TimeUnit unit) does not timeout

    XMLWordPrintable

Details

    Description

      Hi,

      I've written some new tests for DefaultExecutorService for both testing the product as well as for increasing the coverage and I have some strange behaviour which I don't know whether related to concurency non-reliability or it is a bug.

      I have a Callable which just sleeps for 10 seconds and the returns 1. And I have a test, which submits the callable to DefaultExecutorService with invokeAny(collection, timeout, TimeUnit) method, and passes as a parameter to the method 2 seconds. As far as I understand, this means that if the execution of any of the tasks will not complete in 2 seconds, the Timeout exception should be thrown.

      But everytime I run the test, the TimeoutException is thrown only once maybe in 5 executions. The exception is:

      org.testng.TestException:
      Expected exception java.util.concurrent.TimeoutException but got org.testng.TestException:
      Method org.infinispan.distexec.DistributedExecutorTest.testInvokeAnyTimedSleepingTasks() should have thrown an exception of class java.util.concurrent.TimeoutException
      at org.testng.internal.Invoker.handleInvocationResults(Invoker.java:1416)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1184)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
      at org.testng.TestRunner.runWorkers(TestRunner.java:1147)
      at org.testng.TestRunner.privateRun(TestRunner.java:749)
      at org.testng.TestRunner.run(TestRunner.java:600)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:317)
      at org.testng.SuiteRunner.access$000(SuiteRunner.java:34)
      at org.testng.SuiteRunner$SuiteWorker.run(SuiteRunner.java:351)
      at org.testng.internal.thread.ThreadUtil$CountDownLatchedRunnable.run(ThreadUtil.java:147)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
      at java.lang.Thread.run(Thread.java:722)
      Caused by: org.testng.TestException:
      Method org.infinispan.distexec.DistributedExecutorTest.testInvokeAnyTimedSleepingTasks() should have thrown an exception of class java.util.concurrent.TimeoutException
      at org.testng.internal.Invoker.handleInvocationResults(Invoker.java:1442)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:722)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170)
      ... 12 more

      You can find the test attached, the test case is: testInvokeAnyTimedSleepingTasks() .

      Attachments

        Activity

          People

            vblagoje Vladimir Blagojevic (Inactive)
            amanukya@redhat.com Anna Manukyan
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: