Commit 829ac3fb authored by Stephane Nicoll's avatar Stephane Nicoll

Prevent headers to be mutated

This commit rework 1189ccc9 to prevent a mutate call on the original
headers map.

Closes gh-13871
parent 26cab9aa
...@@ -25,6 +25,7 @@ import java.util.Set; ...@@ -25,6 +25,7 @@ import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
...@@ -101,9 +102,9 @@ public class HttpExchangeTracer { ...@@ -101,9 +102,9 @@ public class HttpExchangeTracer {
if (!this.includes.contains(include)) { if (!this.includes.contains(include)) {
return new LinkedHashMap<>(); return new LinkedHashMap<>();
} }
Map<String, List<String>> headers = headersSupplier.get(); return headersSupplier.get().entrySet().stream()
headers.keySet().removeIf((header) -> !headerPredicate.test(header)); .filter((entry) -> headerPredicate.test(entry.getKey()))
return headers; .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
} }
private final class FilteredTraceableRequest implements TraceableRequest { private final class FilteredTraceableRequest implements TraceableRequest {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment