Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeoutException in test next to failed test with timeout #540

Closed
irb1s opened this issue Jun 10, 2013 · 1 comment
Closed

TimeoutException in test next to failed test with timeout #540

irb1s opened this issue Jun 10, 2013 · 1 comment

Comments

@irb1s
Copy link

irb1s commented Jun 10, 2013

cucumber-JVM, ver.1.1.1 (but, I see the code caused the issue still in your repo)

How to reproduce:

  1. Create step with timeout & throw exception in it. e.g.
    @then(value="^I just fail$", timeout=5000)
    public void I_just_fail() throws Throwable {
    Assert.fail("Just fail")
    }
  2. Create several scenarios with one of them 'just fail'
  3. Get in test next (in fact, after 5sec) to failed test TimeoutException:

java.util.concurrent.TimeoutException: Timed out after 5000ms.
at cucumber.runtime.Timeout.timeout(Timeout.java:29)

The exception caused by scheduled task in static method cucumber.runtime.Timeout::timeout(Callback, int) which is not canceled in case if step throws exception (it interrupts current thread after timeout).
This patch solves the issue:

Index: core/src/main/java/cucumber/runtime/Timeout.java
<+>windows-1251
===================================================================
--- core/src/main/java/cucumber/runtime/Timeout.java    (date 1370818741000)
+++ core/src/main/java/cucumber/runtime/Timeout.java    (revision )
@@ -22,11 +22,12 @@
                 }
             }, timeoutMillis, TimeUnit.MILLISECONDS);
             try {
-                T result = callback.call();
-                timer.cancel(true);
-                return result;
+                return callback.call();
             } catch (InterruptedException timeout) {
                 throw new TimeoutException("Timed out after " + timeoutMillis + "ms.");
+            } finally {
+                done.set(true);
+                timer.cancel(true);
             }
         }
     }
@irb1s irb1s closed this as completed Jun 10, 2013
@irb1s irb1s reopened this Jun 10, 2013
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant