diff --git a/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java b/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java index e60bf54c6e51..57980ec033f8 100644 --- a/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java +++ b/server/src/main/java/org/elasticsearch/cluster/InternalClusterInfoService.java @@ -177,12 +177,10 @@ public void onResponse(NodesStatsResponse nodesStatsResponse) { logger.trace("received node stats response"); for (final FailedNodeException failure : nodesStatsResponse.failures()) { - final Throwable cause = failure.getCause(); - if (logger.isDebugEnabled()) { - logger.warn(new ParameterizedMessage("failed to retrieve stats for node [{}]", failure.nodeId()), cause); - } else { - logger.warn("failed to retrieve stats for node [{}]: {}", failure.nodeId(), cause.getMessage()); - } + logger.warn( + new ParameterizedMessage("failed to retrieve stats for node [{}]", failure.nodeId()), + failure.getCause() + ); } ImmutableOpenMap.Builder leastAvailableUsagesBuilder = ImmutableOpenMap.builder(); @@ -223,21 +221,13 @@ public void onResponse(IndicesStatsResponse indicesStatsResponse) { for (final DefaultShardOperationFailedException shardFailure : indicesStatsResponse.getShardFailures()) { if (shardFailure.getCause()instanceof final FailedNodeException failedNodeException) { if (failedNodeIds.add(failedNodeException.nodeId())) { - if (logger.isDebugEnabled()) { - logger.warn( - new ParameterizedMessage( - "failed to retrieve shard stats from node [{}]", - failedNodeException.nodeId() - ), - failedNodeException - ); - } else { - logger.warn( - "failed to retrieve shard stats from node [{}]: {}", - failedNodeException.nodeId(), - failedNodeException.getCause().getMessage() - ); - } + logger.warn( + new ParameterizedMessage( + "failed to retrieve shard stats from node [{}]", + failedNodeException.nodeId() + ), + failedNodeException.getCause() + ); } logger.trace( new ParameterizedMessage(