Skip to content

Commit 7307e37

Browse files
committed
Previously added logging in TransportRefreshAction caused NPE if search shards had errors (or was not yet started/assigned)
Better formatting for logging in TransportRefreshAction
1 parent a48c437 commit 7307e37

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/main/java/org/elasticsearch/action/admin/indices/refresh/TransportRefreshAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected ShardRefreshResponse newShardResponse() {
113113
protected ShardRefreshResponse shardOperation(ShardRefreshRequest request) throws ElasticSearchException {
114114
IndexShard indexShard = indicesService.indexServiceSafe(request.index()).shardSafe(request.shardId());
115115
indexShard.refresh(new Engine.Refresh().force(request.force()));
116-
logger.debug("Refresh request executed for {}. Force: [{}].", indexShard.shardId(), request.force());
116+
logger.debug("{} Refresh request executed. Force: [{}].", indexShard.shardId(), request.force());
117117
return new ShardRefreshResponse(request.index(), request.shardId());
118118
}
119119

src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,13 +390,20 @@ protected final void processFirstPhaseResult(int shardIndex, ShardRouting shard,
390390
final void innerMoveToSecondPhase() throws Exception {
391391
if (logger.isDebugEnabled()) {
392392
StringBuilder sb = new StringBuilder();
393+
boolean hadOne = false;
393394
for (int i = 0; i < firstResults.length(); i++) {
394-
SearchShardTarget shard = firstResults.get(i).shardTarget();
395-
if (i > 0) {
395+
FirstResult result = firstResults.get(i);
396+
if (result == null) {
397+
continue; // failure
398+
}
399+
if (hadOne) {
396400
sb.append(",");
401+
} else {
402+
hadOne = true;
397403
}
398-
sb.append(shard);
404+
sb.append(result.shardTarget());
399405
}
406+
400407
logger.debug("Moving to second phase, based on results from: {}", sb);
401408
}
402409
moveToSecondPhase();

0 commit comments

Comments
 (0)