Assert on request headers only (#57792)
Only assert that actual request headers are empty, as default headers might still be there when stashing the context.
This commit is contained in:
parent
2c6bd978d8
commit
b5d3565214
|
@ -302,6 +302,13 @@ public final class ThreadContext implements Writeable {
|
|||
return Collections.unmodifiableMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the request headers, without the default headers
|
||||
*/
|
||||
public Map<String, String> getRequestHeadersOnly() {
|
||||
return Collections.unmodifiableMap(new HashMap<>(threadLocal.get().requestHeaders));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a copy of all <em>response</em> headers.
|
||||
*
|
||||
|
|
|
@ -62,9 +62,9 @@ public enum Transports {
|
|||
}
|
||||
|
||||
public static boolean assertDefaultThreadContext(ThreadContext threadContext) {
|
||||
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();
|
||||
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();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue