AbstractSearchAsyncAction: fix potential NPE in debug logging

This commit is contained in:
Boaz Leskes 2017-03-23 09:00:38 +01:00
parent 2517cb3062
commit 6577503b37
1 changed files with 2 additions and 1 deletions

View File

@ -122,7 +122,8 @@ abstract class AbstractSearchAsyncAction<Result extends SearchPhaseResult> exten
if (successfulOps.get() == 0) { // we have 0 successful results that means we shortcut stuff and return a failure
if (logger.isDebugEnabled()) {
final ShardOperationFailedException[] shardSearchFailures = ExceptionsHelper.groupBy(buildShardFailures());
Throwable cause = ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0];
Throwable cause = shardSearchFailures.length == 0 ? null :
ElasticsearchException.guessRootCauses(shardSearchFailures[0].getCause())[0];
logger.debug((Supplier<?>) () -> new ParameterizedMessage("All shards failed for phase: [{}]", getName()),
cause);
}