[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

View File

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