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

Running concurrent test fails with java.util.EmptyStackException #13

Open
krop-freenetdigital opened this issue Feb 11, 2015 · 0 comments

Comments

@krop-freenetdigital
Copy link

Using the JBehave feature of running tests concurrently fails under certain circumstances while writing the Thucydides report with the following exception:

[WARNING] Failed to run story stories/booking/Unlock.story

java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.jbehave.core.reporters.ConcurrentStoryReporter$DelayedMethod.invoke(ConcurrentStoryReporter.java:356)
at org.jbehave.core.reporters.ConcurrentStoryReporter.invokeDelayed(ConcurrentStoryReporter.java:335)
at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:230)
at org.jbehave.core.embedder.StoryRunner.run(StoryRunner.java:181)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:262)
at org.jbehave.core.embedder.StoryManager$EnqueuedStory.call(StoryManager.java:229)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
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: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.jbehave.core.reporters.ConcurrentStoryReporter$DelayedMethod.invoke(ConcurrentStoryReporter.java:352)
... 10 more
Caused by: java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)
at java.util.Stack.pop(Stack.java:84)
at net.thucydides.jbehave.ThucydidesReporter.afterScenario(ThucydidesReporter.java:532)
at org.jbehave.core.reporters.DelegatingStoryReporter.afterScenario(DelegatingStoryReporter.java:43)
... 15 more

It is difficult to reproduce because it does not happen on any computer. In our case only to occurs when at least on scenario of a story is failing and multiple stories are used. Even than, it does not happen on every host - because a race condition seems to be involved, but it can be validated by setting some break points. It seems that net.thucydides.jbehave.ThucydidesReporter.activeScenarios is responsible for the failure, which is accessed concurrently by multiple threads.

We have tried out a fix where activeScenarios is accessed via a thread local variable which worked fine on our machines.

Best regards

Tronje

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant