mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-25 22:36:20 +00:00
use close helper method to close streams
This commit is contained in:
parent
76d042f3c5
commit
c4646a2b55
@ -25,6 +25,7 @@ import org.apache.lucene.store.Directory;
|
|||||||
import org.apache.lucene.store.FSDirectory;
|
import org.apache.lucene.store.FSDirectory;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
import org.apache.lucene.store.IndexOutput;
|
import org.apache.lucene.store.IndexOutput;
|
||||||
|
import org.elasticsearch.common.io.Closeables;
|
||||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||||
import org.elasticsearch.index.store.support.ForceSyncDirectory;
|
import org.elasticsearch.index.store.support.ForceSyncDirectory;
|
||||||
|
|
||||||
@ -116,20 +117,8 @@ public class Directories {
|
|||||||
os.write(buffer, 0, toRead);
|
os.write(buffer, 0, toRead);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (os != null) {
|
Closeables.closeQuietly(os);
|
||||||
try {
|
Closeables.closeQuietly(ii);
|
||||||
os.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ii != null) {
|
|
||||||
try {
|
|
||||||
ii.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,20 +137,8 @@ public class Directories {
|
|||||||
output = dir.createOutput(fileName);
|
output = dir.createOutput(fileName);
|
||||||
copyToDirectory(is, output);
|
copyToDirectory(is, output);
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null) {
|
Closeables.closeQuietly(is);
|
||||||
try {
|
Closeables.closeQuietly(output);
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (output != null) {
|
|
||||||
try {
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sync(dir, fileName);
|
sync(dir, fileName);
|
||||||
@ -173,20 +150,8 @@ public class Directories {
|
|||||||
output = dir.createOutput(fileName);
|
output = dir.createOutput(fileName);
|
||||||
copyToDirectory(is, output);
|
copyToDirectory(is, output);
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null) {
|
Closeables.closeQuietly(is);
|
||||||
try {
|
Closeables.closeQuietly(output);
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (output != null) {
|
|
||||||
try {
|
|
||||||
output.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
sync(dir, fileName);
|
sync(dir, fileName);
|
||||||
}
|
}
|
||||||
@ -207,16 +172,8 @@ public class Directories {
|
|||||||
io.writeBytes(buffer, len);
|
io.writeBytes(buffer, len);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
Closeables.closeQuietly(io);
|
||||||
io.close();
|
Closeables.closeQuietly(is);
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user