Repository: pinpoint-apm/pinpoint
Issue: Spring cloud gateway call tree/servermap is incorrect
Labels: bug
module:agent

#### What version of pinpoint are you using?
master/v2.2.2

#### Describe the bug
When the call path is as:  _gateway_(optional) -> _appA_ -> _gateway_(spring cloud gateway with netty-http) -> _appB_, the call tree and the servermap would be incorrect. The call tree after gateway is missing.
                          

>
>                                 ----> gateway ----> unknown (appB's host:port)
>       user ---> appA   __ /
>                            \  
>                                ----->appB
>

It should be:   user ---> appA ---> gateway ---> appB

#### What did you do to trigger the bug?
1. build a gateway by using spring cloud gateway via start.spring.io with dependency Spring Cloud Gateway
2. add a route to _appB_
3. add a java app (_appA_) which pass the request to the _gateway_
All these apps should have pinpoint agent installed.

#### Cause
The pinpoint headers were added by gateway multiple times. The pinpoint headers generated by _appA_ are kept and not replaced by new values generated by the _gateway_.

> T 192.168.1.88:48598 -> 192.168.1.88:16101 [AP] #2737
> GET /user/1000 HTTP/1.1.
> User-Agent: Apache-HttpClient/4.5.6 (Java/1.8.0_xxx).
> Accept-Encoding: gzip,deflate.
> Pinpoint-TraceID: D6569WtHRb2I8kK-41gvEA^1616059917098^10.
> Pinpoint-SpanID: 1929507258409571489.
> Pinpoint-pSpanID: -7870392703037294246.
> Pinpoint-Flags: 0.
> Pinpoint-pAppName: pinpoint-verify.
> Pinpoint-pAppType: 1000.
> Pinpoint-Host: verify.example.com.
> Forwarded: proto=http;host=verify.example.com;for="127.0.0.1:58568".
> X-Forwarded-For: 127.0.0.1.
> X-Forwarded-Proto: http.
> X-Forwarded-Port: 80.
> X-Forwarded-Host: verify.example.com.
> host: 192.168.1.88:16101.
> accept: */*.
> Pinpoint-TraceID: D6569WtHRb2I8kK-41gvEA^1616059917098^10.
> Pinpoint-SpanID: -602080378178433913.
> Pinpoint-pSpanID: 1929507258409571489.
> Pinpoint-Flags: 0.
> Pinpoint-pAppName: gateway-local.
> Pinpoint-pAppType: 1000.
> Pinpoint-Host: 192.168.1.88:16101.





#### Expected behavior
The call tree and server map for the transaction should be correct. 



Issue comments:
Thank you for your contribution.

Pull request review comments:

Patch that resolved the issue:
diff --git a/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpClientRequestHeaderAdaptor.java b/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpClientRequestHeaderAdaptor.java
index b195e6d6a24e..839c462d46f4 100644
--- a/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpClientRequestHeaderAdaptor.java
+++ b/plugins/reactor-netty/src/main/java/com/navercorp/pinpoint/plugin/reactor/netty/interceptor/HttpClientRequestHeaderAdaptor.java
@@ -31,7 +31,11 @@ public class HttpClientRequestHeaderAdaptor implements ClientHeaderAdaptor<HttpC
     @Override
     public void setHeader(final HttpClientRequest request, final String name, final String value) {
         if (request != null) {
-            request.addHeader(name, value);
+            try {
+                request.header(name, value);
+            } catch (IllegalStateException|UnsupportedOperationException e) {
+                logger.warn("Set header {}={} failed, because {}", name, value, e.getMessage());
+            }
             if (isDebug) {
                 logger.debug("Set header {}={}", name, value);
             }


Test patch: