Skip to content

Commit 89883c7

Browse files
committed
Fix minor issues
1 parent e0814cb commit 89883c7

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

core/aws-core/src/main/java/software/amazon/awssdk/awscore/interceptor/TraceIdExecutionInterceptor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ public void onExecutionFailure(Context.FailedExecution context, ExecutionAttribu
7070
}
7171

7272
private static void saveTraceId(ExecutionAttributes executionAttributes) {
73-
MDC.put(CONCURRENT_TRACE_ID_KEY, executionAttributes.getAttribute(TRACE_ID));
73+
String traceId = executionAttributes.getAttribute(TRACE_ID);
74+
if (traceId != null) {
75+
MDC.put(CONCURRENT_TRACE_ID_KEY, executionAttributes.getAttribute(TRACE_ID));
76+
}
7477
}
7578

7679
private Optional<String> traceIdHeader(Context.ModifyHttpRequest context) {

test/codegen-generated-classes-test/src/test/java/software/amazon/awssdk/services/TraceIdTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
/**
3838
* Verifies that the {@link TraceIdExecutionInterceptor} is actually wired up for AWS services.
3939
*/
40-
public class
41-
TraceIdTest {
40+
public class TraceIdTest {
4241
@Test
4342
public void traceIdInterceptorIsEnabled() {
4443
EnvironmentVariableHelper.run(env -> {
@@ -130,7 +129,6 @@ public void traceIdInterceptorPreservesTraceIdAcrossChainedFutures() {
130129

131130
client.allTypes()
132131
.thenRun(() -> {
133-
String traceId = MDC.get("AWS_LAMBDA_X_TRACE_ID");
134132
client.allTypes().join();
135133
})
136134
.join();

0 commit comments

Comments
 (0)