LUCENE-3251: Directory#copy leaks file handles

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1140498 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Simon Willnauer 2011-06-28 09:39:13 +00:00
parent 9e74a6a295
commit aff519123c
2 changed files with 9 additions and 2 deletions

View File

@ -484,6 +484,11 @@ Bug fixes
======================= Lucene 3.x (not yet released) ================
Bug fixes
* LUCENE-3251: Directory#copy failed to close target output if opening the
source stream failed. (Simon Willnauer)
Optimizations
* LUCENE-3201, LUCENE-3218: CompoundFileSystem code has been consolidated

View File

@ -224,10 +224,12 @@ public abstract class Directory implements Closeable {
* overwrite it if it does.
*/
public void copy(Directory to, String src, String dest) throws IOException {
IndexOutput os = to.createOutput(dest);
IndexInput is = openInput(src);
IndexOutput os = null;
IndexInput is = null;
IOException priorException = null;
try {
os = to.createOutput(dest);
is = openInput(src);
is.copyBytes(os, is.length());
} catch (IOException ioe) {
priorException = ioe;