Matching update for copyHeadersIfAbsent

The change to copyHeaders from d46091 also applied to copyHeadersIfPresent.

Closes gh-26155
This commit is contained in:
Rossen Stoyanchev
2020-11-26 21:51:25 +00:00
parent d46091565b
commit 11f6c4e7ab
2 changed files with 40 additions and 8 deletions

View File

@@ -129,6 +129,21 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor {
super.copyHeaders(headersToCopy);
}
@Override
public void copyHeadersIfAbsent(@Nullable Map<String, ?> headersToCopy) {
if (headersToCopy == null) {
return;
}
@SuppressWarnings("unchecked")
Map<String, List<String>> map = (Map<String, List<String>>) headersToCopy.get(NATIVE_HEADERS);
if (map != null && getNativeHeaders() == null) {
map.forEach(this::setNativeHeaderValues);
}
super.copyHeadersIfAbsent(headersToCopy);
}
/**
* Whether the native header map contains the give header name.
* @param headerName the name of the header