thread leak in cucumber.runtime.Timeout class #639

Closed
volna80 opened this Issue Dec 2, 2013 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

volna80 commented Dec 2, 2013

Hi,

If you set timeout for all your steps, and have a lot of scenarios. Cucucmber-jvm falls that it reaches the limit of running threads (the number is depend on OS).

The bug is in cucumber.runtime.Timeout class.

ScheduledFuture<?> timer = Executors.newSingleThreadScheduledExecutor().schedule(new Runnable() {

It creates every time new executor service, but never stop it.

As the result, the number of running threads is growing.

Owner

aslakhellesoy commented Dec 2, 2013

Ouch! Interested in sending a PR with a fix?

Contributor

volna80 commented Dec 2, 2013

Yep, will send it today

Member

ffbit commented Dec 2, 2013

Great thread!
Could you please send us an instruction on how to reproduce the described case?
Thanks in advance.

@volna80 volna80 added a commit to volna80/cucumber-jvm that referenced this issue Dec 2, 2013

@volna80 volna80 fix the thread leak in timeout class (cucumber#639) 561398c
Contributor

volna80 commented Dec 2, 2013

  1. define a step

@When(value = "do nothing", timeout = 60000)
public void doNothing(){
//do nothing
}

  1. write a lot of scenarios which use this step

When do nothing
When do nothing
.....
When do nothing

  1. run it using
    @runwith(Cucumber.class)
    public class RunCukesTest {
    }

Result: Use any java profing and see that the number of live threads are growing

Owner

aslakhellesoy commented Dec 2, 2013

It's possible to count the number of threads with Thread.getAllStackTraces(). This could be leveraged in a test that counts the number of threads before and after and verifies that the number is the same.

Member

ffbit commented Dec 2, 2013

Thanks for the clarification.

@volna80 volna80 added a commit to volna80/cucumber-jvm that referenced this issue Dec 2, 2013

@volna80 volna80 fix the thread leak in timeout class (cucumber#639) 5ca341d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment