From 8199956937dcb0c9a7ab12c42dcf874a8aa311f6 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Tue, 9 Jun 2020 22:24:35 +0200 Subject: [PATCH] Revert "Assert on request headers only (#57792)" This reverts commit b5d3565214dcca3aacbc04c69b0f54098a198d9f. --- .../common/util/concurrent/ThreadContext.java | 7 ------- .../main/java/org/elasticsearch/transport/Transports.java | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java b/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java index 52e469bf26a..ab656423c0b 100644 --- a/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java +++ b/server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java @@ -302,13 +302,6 @@ public final class ThreadContext implements Writeable { return Collections.unmodifiableMap(map); } - /** - * Returns the request headers, without the default headers - */ - public Map getRequestHeadersOnly() { - return Collections.unmodifiableMap(new HashMap<>(threadLocal.get().requestHeaders)); - } - /** * Get a copy of all response headers. * diff --git a/server/src/main/java/org/elasticsearch/transport/Transports.java b/server/src/main/java/org/elasticsearch/transport/Transports.java index 2106c194aab..eeaf9e14a81 100644 --- a/server/src/main/java/org/elasticsearch/transport/Transports.java +++ b/server/src/main/java/org/elasticsearch/transport/Transports.java @@ -62,9 +62,9 @@ public enum Transports { } public static boolean assertDefaultThreadContext(ThreadContext threadContext) { - assert threadContext.getRequestHeadersOnly().isEmpty() || - threadContext.getRequestHeadersOnly().size() == 1 && threadContext.getRequestHeadersOnly().containsKey(Task.X_OPAQUE_ID) : - "expected empty context but was " + threadContext.getRequestHeadersOnly() + " on " + Thread.currentThread().getName(); + assert threadContext.getHeaders().isEmpty() || + threadContext.getHeaders().size() == 1 && threadContext.getHeaders().containsKey(Task.X_OPAQUE_ID) : + "expected empty context but was " + threadContext.getHeaders() + " on " + Thread.currentThread().getName(); return true; } }