Skip to content

Commit

Permalink
Fixes potential NullPointerException on shard closing (#21515)
Browse files Browse the repository at this point in the history
It was possible that in IndexService#closeShard(), an attempt
would be made to close the store where the store was not yet
initialized, throwing a NullPointerException.  This commit
ensures that we do not call close on a store that has not
yet been initialized.
  • Loading branch information
Ali Beyad committed Nov 13, 2016
1 parent 6bb64d5 commit 30f6394
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/main/java/org/elasticsearch/index/IndexService.java
Expand Up @@ -406,7 +406,11 @@ private void closeShard(String reason, ShardId sId, IndexShard indexShard, Store
}
} finally {
try {
store.close();
if (store != null) {
store.close();
} else {
logger.trace("[{}] store not initialized prior to closing shard, nothing to close", shardId);
}
} catch (Exception e) {
logger.warn(
(Supplier<?>) () -> new ParameterizedMessage(
Expand Down

0 comments on commit 30f6394

Please sign in to comment.