From dae8f76c397374354e655add842a2e2874a52acb Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 16:20:54 -0500 Subject: [PATCH] `deserializeSafeFromHeader` uses `context.getHeader(headerName)` instead of `context.getHeaders()` (#2768) (#2771) (cherry picked from commit 7c4e06d323135ef8ab616ff083c420ba26287f18) Co-authored-by: Paras Jain --- .../org/opensearch/security/support/HeaderHelper.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/org/opensearch/security/support/HeaderHelper.java b/src/main/java/org/opensearch/security/support/HeaderHelper.java index d679548c2b..f8b52110fd 100644 --- a/src/main/java/org/opensearch/security/support/HeaderHelper.java +++ b/src/main/java/org/opensearch/security/support/HeaderHelper.java @@ -27,7 +27,6 @@ package org.opensearch.security.support; import java.io.Serializable; -import java.util.Map; import com.google.common.base.Strings; @@ -56,15 +55,8 @@ public static String getSafeFromHeader(final ThreadContext context, final String return null; } - String headerValue = null; - - Map headers = context.getHeaders(); - if (!headers.containsKey(headerName) || (headerValue = headers.get(headerName)) == null) { - return null; - } - if (isInterClusterRequest(context) || isTrustedClusterRequest(context) || isDirectRequest(context)) { - return headerValue; + return context.getHeader(headerName); } return null;