From 424be027283588ac5fb76dffbee1c1cb88e75ff5 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 26 Jun 2018 00:01:45 -0400 Subject: [PATCH] Enhance thread context uniqueness assertion This commit enhances the assertion message when de-duplicating values on a thread context header so that if this assertion trips we can see the values and their correpsonding unique values to understand why this assertion might trip. --- .../elasticsearch/common/util/concurrent/ThreadContext.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 ba72561f0c1..490f3d680e4 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 @@ -489,7 +489,8 @@ public final class ThreadContext implements Closeable, Writeable { final List existingValues = newResponseHeaders.get(key); if (existingValues != null) { final Set existingUniqueValues = existingValues.stream().map(uniqueValue).collect(Collectors.toSet()); - assert existingValues.size() == existingUniqueValues.size(); + assert existingValues.size() == existingUniqueValues.size() : + "existing values: [" + existingValues + "], existing unique values [" + existingUniqueValues + "]"; if (existingUniqueValues.contains(uniqueValue.apply(value))) { return this; }