Skip to content

Fix stop watch thread safety #606

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

Merged
merged 2 commits into from
Oct 16, 2013

Conversation

davebassan
Copy link

Running the cucumber tests in parallel results in a NullPointerException being thrown by the StopWatch stop method as it is not thread safe.

I added a test to replicate the issue and have updated the StopWatch class to be thread safe.

@aslakhellesoy
Copy link
Contributor

LGTM - @brasmusson can you merge this one in please?

@brasmusson
Copy link
Contributor

I'll take care of it.

brasmusson added a commit that referenced this pull request Oct 16, 2013
@brasmusson brasmusson merged commit 0a9edb6 into cucumber:master Oct 16, 2013
@brasmusson
Copy link
Contributor

Merged. Thanks for your effort @davebassan

Long duration = System.nanoTime() - start;
start = null;
Long duration = System.nanoTime() - start.get();
start.set(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be the start.remove() is more appropriate.

@RobinAllen
Copy link

I'm hitting (I believe) this same issue running parallel tests in junit+cucumber-spring.

java.lang.NullPointerException
at cucumber.runtime.StopWatch$1.stop(StopWatch.java:21)
at cucumber.runtime.Runtime.runStep(Runtime.java:296)
at cucumber.runtime.model.StepContainer.runStep(StepContainer.java:44)
at cucumber.runtime.model.StepContainer.runSteps(StepContainer.java:39)
at cucumber.runtime.model.CucumberScenario.runBackground(CucumberScenario.java:49)
at cucumber.runtime.model.CucumberScenario.run(CucumberScenario.java:38)
at cucumber.runtime.junit.ExecutionUnitRunner.run(ExecutionUnitRunner.java:83)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:63)
at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:18)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:70)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:82)
at cucumber.api.junit.Cucumber.runChild(Cucumber.java:41)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:258)
at ...

I'm just wondering if/when the fix likely to make it into a future release?

@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

Successfully merging this pull request may close these issues.

5 participants