From 2aeefceca0844d23826d9cf01582752c69df0185 Mon Sep 17 00:00:00 2001 From: hsoftxl Date: Thu, 29 Oct 2020 10:52:13 +0800 Subject: [PATCH] Make okhttp3 ,feign http9.x plugin to support Java 14 (#5745) --- CHANGES.md | 2 ++ .../plugin/feign/http/v9/DefaultHttpClientInterceptor.java | 5 ----- .../apm/plugin/okhttp/v3/AsyncCallInterceptor.java | 5 ----- .../skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java | 5 ----- 4 files changed, 2 insertions(+), 15 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a51838162..6dd064aee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,8 @@ Release Notes. #### Project #### Java Agent +Make the Feign plugin to support Java 14 +Make the okhttp3 plugin to support Java 14 #### OAP-Backend * Add the `@SuperDataset` annotation for BrowserErrorLog. diff --git a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java index 9a27a3534..c3c5861c8 100644 --- a/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/feign-default-http-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/feign/http/v9/DefaultHttpClientInterceptor.java @@ -22,7 +22,6 @@ import feign.Request; import feign.Response; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import java.net.URL; import java.util.ArrayList; import java.util.Collection; @@ -103,10 +102,6 @@ public class DefaultHttpClientInterceptor implements InstanceMethodsAroundInterc } Field headersField = Request.class.getDeclaredField("headers"); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(headersField, headersField.getModifiers() & ~Modifier.FINAL); - headersField.setAccessible(true); Map> headers = new LinkedHashMap>(); CarrierItem next = contextCarrier.items(); 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 7ea109c19..fa9d78993 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 @@ -20,7 +20,6 @@ package org.apache.skywalking.apm.plugin.okhttp.v3; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.Request; @@ -74,10 +73,6 @@ public class AsyncCallInterceptor implements InstanceConstructorInterceptor, Ins SpanLayer.asHttp(span); Field headersField = Request.class.getDeclaredField("headers"); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(headersField, headersField.getModifiers() & ~Modifier.FINAL); - headersField.setAccessible(true); Headers.Builder headerBuilder = request.headers().newBuilder(); CarrierItem next = contextCarrier.items(); diff --git a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java index 56f99a448..8b1a12b2b 100644 --- a/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/okhttp-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/okhttp/v3/RealCallInterceptor.java @@ -20,7 +20,6 @@ package org.apache.skywalking.apm.plugin.okhttp.v3; import java.lang.reflect.Field; import java.lang.reflect.Method; -import java.lang.reflect.Modifier; import okhttp3.Headers; import okhttp3.HttpUrl; import okhttp3.Request; @@ -70,10 +69,6 @@ public class RealCallInterceptor implements InstanceMethodsAroundInterceptor, In SpanLayer.asHttp(span); Field headersField = Request.class.getDeclaredField("headers"); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - modifiersField.setInt(headersField, headersField.getModifiers() & ~Modifier.FINAL); - headersField.setAccessible(true); Headers.Builder headerBuilder = request.headers().newBuilder(); CarrierItem next = contextCarrier.items();