From f21d73ef553c1986872bf973ee70da219a7204c7 Mon Sep 17 00:00:00 2001 From: Owais Kazi Date: Fri, 23 Jun 2023 14:43:50 -0700 Subject: [PATCH] [Extensions] Fixed duplicate extension unique id (#8228) * Fixes duplicate extension unique id Signed-off-by: Owais Kazi * Handled different extension unique id Signed-off-by: Owais Kazi --------- Signed-off-by: Owais Kazi --- .../main/java/org/opensearch/transport/TransportService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/transport/TransportService.java b/server/src/main/java/org/opensearch/transport/TransportService.java index f41112d69196b..021bf39fc5a1f 100644 --- a/server/src/main/java/org/opensearch/transport/TransportService.java +++ b/server/src/main/java/org/opensearch/transport/TransportService.java @@ -544,7 +544,10 @@ public ConnectionManager.ConnectionValidator connectionValidatorForExtensionConn ) { return (newConnection, actualProfile, listener) -> { // We don't validate cluster names to allow for CCS connections. - threadPool.getThreadContext().putHeader("extension_unique_id", extensionUniqueId); + String currentId = threadPool.getThreadContext().getHeader("extension_unique_id"); + if (Strings.isNullOrEmpty(currentId) || !extensionUniqueId.equals(currentId)) { + threadPool.getThreadContext().putHeader("extension_unique_id", extensionUniqueId); + } handshake(newConnection, actualProfile.getHandshakeTimeout().millis(), cn -> true, ActionListener.map(listener, resp -> { final DiscoveryNode remote = resp.discoveryNode;