diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 68077cdb17..e78d77211a 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -34,6 +34,7 @@ Use subheadings with the "=====" level for adding notes for unreleased changes: [float] ===== Features * Added support for OpenTelemetry annotations - `WithSpan` and `SpanAttribute` - {pull}3406[#3406] +* Only automatically apply redacted exceptions for Corretto JVM 17-20. Outside that, user should use capture_exception_details=false to workaround the JVM race-condition bug if it gets triggered: {pull}3438[#3438] [[release-notes-1.x]] === Java Agent version 1.x diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java index ccc7dfa58a..a223dba6a3 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/main/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentation.java @@ -137,7 +137,8 @@ public static void exitDoExecute(@Advice.Argument(value = 0) ClientExecutionPara Span span = (Span) spanObj; span.deactivate(); if (thrown != null) { - if (JVM_RUNTIME_INFO.isCoretto() && JVM_RUNTIME_INFO.getMajorVersion() > 16) { + //Only automatically apply this workaround for JVM 17-20. Outside that, user should use capture_exception_details + if (JVM_RUNTIME_INFO.isCoretto() && JVM_RUNTIME_INFO.getMajorVersion() > 16 && JVM_RUNTIME_INFO.getMajorVersion() < 21) { span.captureException(RedactedException.getInstance(thiz.getClass().getName())); } else { span.captureException(thrown); diff --git a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java index c1bf45a01c..e6d0bf528e 100644 --- a/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java +++ b/apm-agent-plugins/apm-aws-sdk/apm-aws-sdk-2-plugin/src/test/java/co/elastic/apm/agent/awssdk/v2/BaseSyncClientHandlerInstrumentationTest.java @@ -69,6 +69,15 @@ public void checkRedactedExceptionWhenExceptionThrownOnCorretto17() { assertThat(BaseSyncClientHandlerInstrumentation.RedactedException.Exceptions.get(this.getClass().getName())).isNotNull(); } + @Test + public void checkNoRedactedExceptionWhenExceptionThrownOnCorretto21() { + BaseSyncClientHandlerInstrumentation.JVM_RUNTIME_INFO = new JvmRuntimeInfo("21.0.1", "OpenJDK 64-Bit Server VM", "Amazon.com Inc.", "17.0.5+8-LTS"); + assertThat(BaseSyncClientHandlerInstrumentation.JVM_RUNTIME_INFO.isCoretto()).isTrue(); + assertThat(BaseSyncClientHandlerInstrumentation.JVM_RUNTIME_INFO.getMajorVersion()).isGreaterThan(16); + assertThat(exerciseRedactedException(new Exception("test3"))).isEqualTo(Outcome.FAILURE); + assertThat(BaseSyncClientHandlerInstrumentation.RedactedException.Exceptions).isEmpty(); + } + public Outcome exerciseRedactedException(Exception canBeNull) { MockTracer.MockInstrumentationSetup mockInstrumentationSetup = MockTracer.createMockInstrumentationSetup(); ElasticApmTracer tracer = mockInstrumentationSetup.getTracer();