diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java index c3b37ef7be8..f3099db08e9 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequest.java @@ -31,6 +31,7 @@ import org.elasticsearch.rest.RestRequest; import org.elasticsearch.transport.netty4.Netty4Utils; import java.net.SocketAddress; +import java.util.AbstractMap; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -199,23 +200,8 @@ public class Netty4HttpRequest extends RestRequest { @Override public Set>> entrySet() { - return httpHeaders.names().stream().map(k -> new Entry>() { - - @Override - public String getKey() { - return k; - } - - @Override - public List getValue() { - return httpHeaders.getAll(k); - } - - @Override - public List setValue(List value) { - throw new UnsupportedOperationException("modifications are not supported"); - } - }).collect(Collectors.toSet()); + return httpHeaders.names().stream().map(k -> new AbstractMap.SimpleImmutableEntry<>(k, httpHeaders.getAll(k))) + .collect(Collectors.toSet()); } } }