cucumber/cucumber-jvm — pull request #173 by dkowis (2012-01-25 05:48:16+00:00)
Title: We need to flush our FileWriter's created in cucumber-core

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?