Browse Source

Previously added logging in TransportRefreshAction caused NPE if search shards had errors (or was not yet started/assigned)
Better formatting for logging in TransportRefreshAction

Boaz Leskes 12 years ago
parent
commit
7307e37efe

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

@@ -113,7 +113,7 @@ public class TransportRefreshAction extends TransportBroadcastOperationAction<Re
     protected ShardRefreshResponse shardOperation(ShardRefreshRequest request) throws ElasticSearchException {
         IndexShard indexShard = indicesService.indexServiceSafe(request.index()).shardSafe(request.shardId());
         indexShard.refresh(new Engine.Refresh().force(request.force()));
-        logger.debug("Refresh request executed for {}. Force: [{}].", indexShard.shardId(), request.force());
+        logger.debug("{} Refresh request executed. Force: [{}].", indexShard.shardId(), request.force());
         return new ShardRefreshResponse(request.index(), request.shardId());
     }
 

+ 10 - 3
src/main/java/org/elasticsearch/action/search/type/TransportSearchTypeAction.java

@@ -390,13 +390,20 @@ public abstract class TransportSearchTypeAction extends TransportAction<SearchRe
         final void innerMoveToSecondPhase() throws Exception {
             if (logger.isDebugEnabled()) {
                 StringBuilder sb = new StringBuilder();
+                boolean hadOne = false;
                 for (int i = 0; i < firstResults.length(); i++) {
-                    SearchShardTarget shard = firstResults.get(i).shardTarget();
-                    if (i > 0) {
+                    FirstResult result = firstResults.get(i);
+                    if (result == null) {
+                        continue; // failure
+                    }
+                    if (hadOne) {
                         sb.append(",");
+                    } else {
+                        hadOne = true;
                     }
-                    sb.append(shard);
+                    sb.append(result.shardTarget());
                 }
+
                 logger.debug("Moving to second phase, based on results from: {}", sb);
             }
             moveToSecondPhase();