diff --git a/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java b/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java index e1366e13e..fa9f7a645 100755 --- a/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java +++ b/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java @@ -142,6 +142,8 @@ public class HierarchicalMicroScheduler extends MicroScheduler implements Hierar printOnTraversalDone(result); + getOutputTracker().close(); + return result; } diff --git a/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java b/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java index d525f3b7c..246472358 100644 --- a/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java +++ b/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java @@ -59,6 +59,8 @@ public class LinearMicroScheduler extends MicroScheduler { printOnTraversalDone(result); + getOutputTracker().close(); + return accumulator; } diff --git a/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java b/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java index 69a0be1f7..82c587d73 100755 --- a/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java +++ b/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java @@ -65,19 +65,16 @@ public abstract class OutputTracker { // Otherwise, initialize them separately. if( outFileName != null && outFileName.equals(errFileName) ) { outStub = errStub = new OutputStreamStub(new File(outFileName)); - outStub.register(this); - outputs.put(outStub,null); + addOutput(outStub); } else { outStub = (outFileName != null) ? new OutputStreamStub(new File(outFileName)) : new OutputStreamStub(System.out); - outStub.register(this); - outputs.put(outStub,null); + addOutput(outStub); errStub = (errFileName != null) ? new OutputStreamStub(new File(errFileName)) : new OutputStreamStub(System.err); - errStub.register(this); - outputs.put(errStub,null); + addOutput(errStub); } } @@ -127,6 +124,20 @@ public abstract class OutputTracker { outputs.put(stub,null); } + /** + * Close down all existing output streams. + */ + public void close() { + for( Stub stub: outputs.keySet() ) { + // If the stream hasn't yet been created, create it so that there's at least an empty file present. + if( outputs.get(stub) == null ) + getTargetStream(stub); + + // Close down the storage. + outputs.get(stub).close(); + } + } + /** * Collects the target stream for this data. * @param stub The stub for this stream.