Make sure the storage writer is closed before running mergeInfo in multi-threaded output management

-- It's not clear this is cause of GSA-484 but it will help confirm that it's not the cause
This commit is contained in:
Mark DePristo 2012-08-16 10:56:07 -04:00
parent 7a247df922
commit 52bfe8db8a
1 changed files with 4 additions and 0 deletions

View File

@ -61,6 +61,7 @@ public class VariantContextWriterStorage implements Storage<VariantContextWriter
protected final File file;
protected OutputStream stream;
protected final VariantContextWriter writer;
boolean closed = false;
/**
* Constructs an object which will write directly into the output file provided by the stub.
@ -172,10 +173,13 @@ public class VariantContextWriterStorage implements Storage<VariantContextWriter
if(file != null)
logger.debug("Closing temporary file " + file.getAbsolutePath());
writer.close();
closed = true;
}
public void mergeInto(VariantContextWriterStorage target) {
try {
if ( ! closed )
throw new ReviewedStingException("Writer not closed, but we are merging into the file!");
final String targetFilePath = target.file != null ? target.file.getAbsolutePath() : "/dev/stdin";
logger.debug(String.format("Merging %s into %s",file.getAbsolutePath(),targetFilePath));