Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let Corretto 21+ have non-redacted exceptions #3438

Merged
merged 7 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading