mirror of https://github.com/apache/lucene.git
LUCENE-4070: assign output to member to prevent double opening on error
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1340514 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5efed3447e
commit
a0493e5570
|
@ -118,16 +118,14 @@ final class CompoundFileWriter implements Closeable{
|
|||
|
||||
private synchronized IndexOutput getOutput() throws IOException {
|
||||
if (dataOut == null) {
|
||||
IndexOutput dataOutput = null;
|
||||
boolean success = false;
|
||||
try {
|
||||
dataOutput = directory.createOutput(dataFileName, IOContext.DEFAULT);
|
||||
dataOutput.writeVInt(FORMAT_CURRENT);
|
||||
dataOut = dataOutput;
|
||||
dataOut = directory.createOutput(dataFileName, IOContext.DEFAULT);
|
||||
dataOut.writeVInt(FORMAT_CURRENT);
|
||||
success = true;
|
||||
} finally {
|
||||
if (!success) {
|
||||
IOUtils.closeWhileHandlingException(dataOutput);
|
||||
IOUtils.closeWhileHandlingException(dataOut);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue