mirror of https://github.com/apache/lucene.git
LUCENE-3892: close IndexOutput on exception
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/pforcodec_3892@1359299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7afaab4589
commit
cda371db21
|
@ -45,7 +45,17 @@ public final class ForFactory extends IntStreamFactory {
|
|||
|
||||
@Override
|
||||
public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException {
|
||||
return new ForIndexOutput(dir.createOutput(fileName, context), blockSize);
|
||||
boolean success = false;
|
||||
IndexOutput out = dir.createOutput(fileName, context);
|
||||
try {
|
||||
IntIndexOutput ret = new ForIndexOutput(out, blockSize);
|
||||
success = true;
|
||||
return ret;
|
||||
} finally {
|
||||
if (!success) {
|
||||
IOUtils.closeWhileHandlingException(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,7 +45,17 @@ public final class PForFactory extends IntStreamFactory {
|
|||
|
||||
@Override
|
||||
public IntIndexOutput createOutput(Directory dir, String fileName, IOContext context) throws IOException {
|
||||
return new PForIndexOutput(dir.createOutput(fileName, context), blockSize);
|
||||
boolean success = false;
|
||||
IndexOutput out = dir.createOutput(fileName, context);
|
||||
try {
|
||||
IntIndexOutput ret = new PForIndexOutput(out, blockSize);
|
||||
success = true;
|
||||
return ret;
|
||||
} finally {
|
||||
if (!success) {
|
||||
IOUtils.closeWhileHandlingException(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue