From 408bd3db5c7abb15d09256eb801d8902ccc85b9b Mon Sep 17 00:00:00 2001 From: zifeihan Date: Fri, 27 Nov 2020 22:31:39 +0800 Subject: [PATCH] Fix okhttp-3.x and async-http-client-2.x did not overwrite the old trace header. (#5917) * Fix okhttp-3.x and async-http-client-2.x did not overwrite the old trace header. --- .../apm/plugin/asynchttpclient/v2/ExecuteInterceptor.java | 2 +- .../skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java | 2 +- changes/changes-8.3.0.md | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apm-sniffer/apm-sdk-plugin/asynchttpclient-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/asynchttpclient/v2/ExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/asynchttpclient-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/asynchttpclient/v2/ExecuteInterceptor.java index ab1b366322..42f66404c8 100644 --- a/apm-sniffer/apm-sdk-plugin/asynchttpclient-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/asynchttpclient/v2/ExecuteInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/asynchttpclient-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/asynchttpclient/v2/ExecuteInterceptor.java @@ -65,7 +65,7 @@ public class ExecuteInterceptor implements InstanceMethodsAroundInterceptor { CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); - headers.add(next.getHeadKey(), next.getHeadValue()); + headers.set(next.getHeadKey(), next.getHeadValue()); } } diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java index fa9d789934..452b5ba463 100644 --- a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/AsyncCallInterceptor.java @@ -78,7 +78,7 @@ public class AsyncCallInterceptor implements InstanceConstructorInterceptor, Ins CarrierItem next = contextCarrier.items(); while (next.hasNext()) { next = next.next(); - headerBuilder.add(next.getHeadKey(), next.getHeadValue()); + headerBuilder.set(next.getHeadKey(), next.getHeadValue()); } headersField.set(request, headerBuilder.build()); diff --git a/changes/changes-8.3.0.md b/changes/changes-8.3.0.md index 7f4f5aec28..63dda16256 100644 --- a/changes/changes-8.3.0.md +++ b/changes/changes-8.3.0.md @@ -23,6 +23,7 @@ Release Notes. * Fix the default ignore mechanism isn't accurate enough bug. * Add the plugin for spring-kafka 1.3.x. * Add the plugin for Apache CXF 3.x. +* Fix okhttp-3.x and async-http-client-2.x did not overwrite the old trace header. #### OAP-Backend * Add the `@SuperDataset` annotation for BrowserErrorLog.