Skip to content
This repository has been archived by the owner on May 28, 2019. It is now read-only.

JSON Formatter is not thread safe #230

Open
joshughes opened this issue Feb 10, 2013 · 4 comments
Open

JSON Formatter is not thread safe #230

joshughes opened this issue Feb 10, 2013 · 4 comments

Comments

@joshughes
Copy link
Contributor

When running Cucumber tests in parallel only the last RunCukes.java class to be executed writes to the json report. This is a problem for anyone that consumes the report downstream. @rexhoffman mentioned this would be easy to do.

@aslakhellesoy
Copy link
Contributor

I don't think we'll attempt to make any reporters thread safe. I think it's easier to fix Cucumber so it only accesses reporters from a single thread.

WDYT?

@rexhoffman
Copy link

Fixing the internals of cucumber-jvm to support multithreading while maintaining the committed to api for reporters/formatters will be difficult at best (some of the implicit contracts about ordering will need to be broken). I'd rather see cucumber-jvm execute in a thread safe way.

To get there, it might be interesting to attempt this by making the json formatter, have it act as an intermediary holder of state, until passing it off to other real formatters. Internal state storage needs to happen somewhere.... the json reporter could become a report aggregator and proxy.

Refactor-rinse-repeat?

@ghost
Copy link

ghost commented Oct 11, 2013

In my project we are using parallel test, cucumber and Gherkin gesm to generate the HTML reports. In the project we are using JSONFormatter to write a json, due to multithreaded environment it is giving us malformed JSON every time. Please refer the attachment for the same.

If you have any solution to synchronize the threads while writing on JSON then please suggest us,
Tons of thanks in advance.
json1

@mngenius
Copy link

in Gherkin library, they just need to move to google Gson, whivch is maintaining a ThreadLoacl, instead of their Gson, which uses a HashMap

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

4 participants