From 5b70521066d186053839cf4182df05629da6b53f Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Thu, 29 Jul 2021 10:47:10 +0200 Subject: [PATCH 1/5] simple work-around to make our usage of jackson compatible with jdk16 --- .../java/co/elastic/apm/agent/JsonUtils.java | 25 ++++++++++++++++++- pom.xml | 3 ++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/JsonUtils.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/JsonUtils.java index 9a68a53736..c98519534e 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/JsonUtils.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/JsonUtils.java @@ -18,12 +18,35 @@ */ package co.elastic.apm.agent; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; + +import java.io.IOException; +import java.nio.CharBuffer; public class JsonUtils { - private static final ObjectMapper objectMapper = new ObjectMapper(); + private static final ObjectMapper objectMapper; + + static { + objectMapper = new ObjectMapper(); + + // using default serializer for CharBuffer will try to make some properties accessible using introspection + // which fails with Java 15+ and we don't need in practice, thus using a custom serializer allows to avoid this. + SimpleModule module = new SimpleModule(); + module.addSerializer(CharBuffer.class, new StdSerializer(CharBuffer.class) { + + @Override + public void serialize(CharBuffer charBuffer, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + jsonGenerator.writeString(charBuffer.toString()); + } + }); + objectMapper.registerModule(module); + } public static JsonNode toJson(Object o) { return objectMapper.valueToTree(o); diff --git a/pom.xml b/pom.xml index f0e7eaa202..c26475b9fc 100644 --- a/pom.xml +++ b/pom.xml @@ -96,7 +96,8 @@ 2.2.0 1.4.196 - [2.10.0,) + + 2.12.4 5.7.2 4.13.2 5.7.2 From 2ba9faa8405fe1ee70d0acbc5a1fd07aad8e6e05 Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Thu, 29 Jul 2021 11:10:44 +0200 Subject: [PATCH 2/5] fix version range to exclude jackson 2.13 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c26475b9fc..4abc7df7f1 100644 --- a/pom.xml +++ b/pom.xml @@ -97,7 +97,7 @@ 2.2.0 1.4.196 - 2.12.4 + [2.12.4,2.12.99999) 5.7.2 4.13.2 5.7.2 From 7d85d3b700a13fbf0336bb3cc89fc87973f3f8b2 Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Mon, 2 Aug 2021 13:51:03 +0200 Subject: [PATCH 3/5] ignore known test failures on jdk 15 --- .../java/co/elastic/apm/agent/bci/InstrumentationTest.java | 5 +++++ .../co/elastic/apm/agent/impl/payload/ContainerInfoTest.java | 3 +++ pom.xml | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java index d04039af56..0a1123a590 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java @@ -43,6 +43,8 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnJre; +import org.junit.jupiter.api.condition.JRE; import org.slf4j.event.SubstituteLoggingEvent; import org.stagemonitor.configuration.ConfigurationRegistry; @@ -292,6 +294,7 @@ void testPatchClassFileVersionJava6ToJava7() { } @Test + @DisabledOnJre(JRE.JAVA_15) void testPatchClassFileVersionJava5ToJava7() { // loading classes compiled with bytecode level 49 (Java 6) new org.slf4j.event.SubstituteLoggingEvent(); @@ -311,6 +314,7 @@ void testPatchClassFileVersionJava5ToJava7() { } @Test + @DisabledOnJre(JRE.JAVA_15) void testPatchClassFileVersionJava5ToJava7CommonsMath() { org.apache.commons.math3.stat.StatUtils.max(new double[]{3.14}); @@ -329,6 +333,7 @@ void testPatchClassFileVersionJava5ToJava7CommonsMath() { } @Test + @DisabledOnJre(JRE.JAVA_15) void testPatchClassFileVersionJava4ToJava7CommonsMath() { org.apache.log4j.LogManager.exists("not"); diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/payload/ContainerInfoTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/payload/ContainerInfoTest.java index 1ab645fd3b..094a809fd5 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/payload/ContainerInfoTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/impl/payload/ContainerInfoTest.java @@ -19,6 +19,8 @@ package co.elastic.apm.agent.impl.payload; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnJre; +import org.junit.jupiter.api.condition.JRE; import javax.annotation.Nullable; @@ -117,6 +119,7 @@ void testKubernetesInfo_podUid_with_underscores() { } @Test + @DisabledOnJre({JRE.JAVA_15, JRE.JAVA_16}) // https://github.com/elastic/apm-agent-java/issues/1942 void testKubernetesDownwardApi() throws Exception { String line = "1:name=systemd:/kubepods/besteffort/pode9b90526-f47d-11e8-b2a5-080027b9f4fb/15aa6e53-b09a-40c7-8558-c6c31e36c88a"; String containerId = "15aa6e53-b09a-40c7-8558-c6c31e36c88a"; diff --git a/pom.xml b/pom.xml index 4abc7df7f1..4115941ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -96,8 +96,7 @@ 2.2.0 1.4.196 - - [2.12.4,2.12.99999) + [2.10.0,) 5.7.2 4.13.2 5.7.2 @@ -357,6 +356,7 @@ org.jacoco jacoco-maven-plugin + 0.8.7 From df7d99457adabbe4c975338fb82165d94835eea1 Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Mon, 2 Aug 2021 14:01:18 +0200 Subject: [PATCH 4/5] add known issue links --- .../java/co/elastic/apm/agent/bci/InstrumentationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java b/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java index 0a1123a590..c5c8ccdc62 100644 --- a/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java +++ b/apm-agent-core/src/test/java/co/elastic/apm/agent/bci/InstrumentationTest.java @@ -294,7 +294,7 @@ void testPatchClassFileVersionJava6ToJava7() { } @Test - @DisabledOnJre(JRE.JAVA_15) + @DisabledOnJre(JRE.JAVA_15) // https://github.com/elastic/apm-agent-java/issues/1944 void testPatchClassFileVersionJava5ToJava7() { // loading classes compiled with bytecode level 49 (Java 6) new org.slf4j.event.SubstituteLoggingEvent(); @@ -314,7 +314,7 @@ void testPatchClassFileVersionJava5ToJava7() { } @Test - @DisabledOnJre(JRE.JAVA_15) + @DisabledOnJre(JRE.JAVA_15) // https://github.com/elastic/apm-agent-java/issues/1944 void testPatchClassFileVersionJava5ToJava7CommonsMath() { org.apache.commons.math3.stat.StatUtils.max(new double[]{3.14}); @@ -333,7 +333,7 @@ void testPatchClassFileVersionJava5ToJava7CommonsMath() { } @Test - @DisabledOnJre(JRE.JAVA_15) + @DisabledOnJre(JRE.JAVA_15) // https://github.com/elastic/apm-agent-java/issues/1944 void testPatchClassFileVersionJava4ToJava7CommonsMath() { org.apache.log4j.LogManager.exists("not"); From 3adc2ab79b7377f63838033f8f09a0dc9767c184 Mon Sep 17 00:00:00 2001 From: Sylvain Juge Date: Mon, 2 Aug 2021 14:58:18 +0200 Subject: [PATCH 5/5] update groovy version for recent JDK --- apm-agent-plugins/apm-grails-plugin/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-agent-plugins/apm-grails-plugin/pom.xml b/apm-agent-plugins/apm-grails-plugin/pom.xml index 9ddde33a07..dc8283897c 100644 --- a/apm-agent-plugins/apm-grails-plugin/pom.xml +++ b/apm-agent-plugins/apm-grails-plugin/pom.xml @@ -19,7 +19,7 @@ org.grails grails-web-mvc - 4.0.3 + 4.1.0.M4 provided