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

Already on GitHub? Sign in to your account

We need to flush our FileWriter's created in cucumber-core #173

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Member

dkowis commented Jan 25, 2012

System.exit(int) doesn't appear to ensure that our FileWriters are flushed, and so any output configured to go to files, doesn't.

I found this bug (#172) when running against our project, barfing out JSON to a file to see what I could do with that in terms of reporting, and or giving it to someone else for ingestion.

Then, noticing that it didn't output all the data, I tried adding it to the jruby project in cucumber-jvm, just to have a smallish starting point. Turns out nothing was making it into the output file, but if I barfed to the console, everything showed up! Our file writers weren't being flushed.

This adds a shutdown hook only for the filewriters we create, and calls flush on them. I suppose it could call close, but flushing them seems to get the job done.

Opinions? Should we be doing this entirely differently?

Owner

aslakhellesoy commented Jan 25, 2012

The bug was in Gherkin's own formatters. At the end of the run, Formatter.done() is called, it just wasn't doing the appropriate flush()/close().

@aslakhellesoy aslakhellesoy reopened this Jan 25, 2012

Owner

aslakhellesoy commented Jan 25, 2012

I spoke too soon. I first did cucumber-attic/gherkin@ac0cc51 and then reverted it with cucumber-attic/gherkin@f432f28

We definitely need to close the streams in cucumber-jvm. I'm not happy with the shutdown hook approach though - shutdown hooks are not guaranteed to run.

Owner

aslakhellesoy commented Jan 25, 2012

@dkowis Take a look at how I did it. I think that's a cleaner solution.

Member

dkowis commented Jan 25, 2012

@aslakhellesoy Totally. That's a much cleaner solution. I wasn't sure that making changes to gherkin was a good idea, but I like this a lot. Works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment