[CORE] close all resources even if #beforeIndexShardClosed throws an exception

Conflicts:
	src/main/java/org/elasticsearch/index/IndexService.java
This commit is contained in:
Simon Willnauer 2015-02-21 14:22:53 +01:00
parent 16f19bf7bd
commit 3e2f4b86e4
1 changed files with 31 additions and 27 deletions

View File

@ -375,8 +375,11 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
private void closeShardInjector(String reason, ShardId sId, Injector shardInjector, IndexShard indexShard) {
final int shardId = sId.id();
try {
try {
indicesLifecycle.beforeIndexShardClosed(sId, indexShard, indexSettings);
} finally {
// close everything else even if the beforeIndexShardClosed threw an exception
for (Class<? extends Closeable> closeable : pluginsService.shardServices()) {
try {
shardInjector.getInstance(closeable).close();
@ -406,6 +409,7 @@ public class IndexService extends AbstractIndexComponent implements IndexCompone
// call this before we close the store, so we can release resources for it
indicesLifecycle.afterIndexShardClosed(sId, indexShard, indexSettings);
}
} finally {
try {
shardInjector.getInstance(Store.class).close();