diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java index 05cf60703d9..32f3d8a2769 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/info/NodesInfoResponse.java @@ -32,7 +32,6 @@ import org.elasticsearch.common.xcontent.XContentFactory; import java.io.IOException; import java.util.Map; -import java.util.stream.Collectors; /** * @@ -86,8 +85,11 @@ public class NodesInfoResponse extends BaseNodesResponse implements To } } - builder.array("roles", nodeInfo.getNode().getRoles().stream().map(DiscoveryNode.Role::getRoleName) - .collect(Collectors.toList()).toArray()); + builder.startArray("roles"); + for (DiscoveryNode.Role role : nodeInfo.getNode().getRoles()) { + builder.value(role.getRoleName()); + } + builder.endArray(); if (!nodeInfo.getNode().attributes().isEmpty()) { builder.startObject("attributes"); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java index 54e96a67c53..3424a88d3b6 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java @@ -41,7 +41,6 @@ import org.elasticsearch.threadpool.ThreadPoolStats; import org.elasticsearch.transport.TransportStats; import java.io.IOException; -import java.util.stream.Collectors; /** * Node statistics (dynamic, changes depending on when created). @@ -305,8 +304,11 @@ public class NodeStats extends BaseNodeResponse implements ToXContent { builder.field("host", getNode().getHostName(), XContentBuilder.FieldCaseConversion.NONE); builder.field("ip", getNode().getAddress(), XContentBuilder.FieldCaseConversion.NONE); - builder.array("roles", getNode().getRoles().stream().map(DiscoveryNode.Role::getRoleName) - .collect(Collectors.toList()).toArray()); + builder.startArray("roles"); + for (DiscoveryNode.Role role : getNode().getRoles()) { + builder.value(role.getRoleName()); + } + builder.endArray(); if (!getNode().attributes().isEmpty()) { builder.startObject("attributes"); diff --git a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java index 2a36a6fe6d0..fcf23971d12 100644 --- a/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java +++ b/core/src/main/java/org/elasticsearch/action/admin/cluster/node/tasks/list/ListTasksResponse.java @@ -20,7 +20,6 @@ package org.elasticsearch.action.admin.cluster.node.tasks.list; import com.carrotsearch.hppc.cursors.ObjectObjectCursor; - import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.TaskOperationFailure; import org.elasticsearch.action.support.tasks.BaseTasksResponse; @@ -39,7 +38,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.stream.Collectors; /** * Returns the list of tasks currently running on the nodes @@ -132,8 +130,11 @@ public class ListTasksResponse extends BaseTasksResponse implements ToXContent { builder.field("host", node.getHostName()); builder.field("ip", node.getAddress()); - builder.array("roles", node.getRoles().stream().map(DiscoveryNode.Role::getRoleName) - .collect(Collectors.toList()).toArray()); + builder.startArray("roles"); + for (DiscoveryNode.Role role : node.getRoles()) { + builder.value(role.getRoleName()); + } + builder.endArray(); if (!node.attributes().isEmpty()) { builder.startObject("attributes");