From 35b143a7ac16384fc914e160374127cfab941d88 Mon Sep 17 00:00:00 2001 From: Jonas Rutishauser Date: Thu, 18 Jan 2024 19:26:09 +0100 Subject: [PATCH] Correctly fix NPE in servlet AsyncListener (#10250) --- .../instrumentation/servlet/v3_0/Servlet3Accessor.java | 4 +++- .../instrumentation/servlet/v5_0/Servlet5Accessor.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3Accessor.java b/instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3Accessor.java index 2a6b1be02fcb..8e9740a63de9 100644 --- a/instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3Accessor.java +++ b/instrumentation/servlet/servlet-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v3_0/Servlet3Accessor.java @@ -101,7 +101,9 @@ public void onError(AsyncEvent event) { @Override public void onStartAsync(AsyncEvent event) { - event.getAsyncContext().addListener(this); + event + .getAsyncContext() + .addListener(this, event.getSuppliedRequest(), event.getSuppliedResponse()); } } } diff --git a/instrumentation/servlet/servlet-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/Servlet5Accessor.java b/instrumentation/servlet/servlet-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/Servlet5Accessor.java index 2a22a9ecf2c6..b902885655f6 100644 --- a/instrumentation/servlet/servlet-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/Servlet5Accessor.java +++ b/instrumentation/servlet/servlet-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/Servlet5Accessor.java @@ -194,7 +194,9 @@ public void onError(AsyncEvent event) { @Override public void onStartAsync(AsyncEvent event) { - event.getAsyncContext().addListener(this); + event + .getAsyncContext() + .addListener(this, event.getSuppliedRequest(), event.getSuppliedResponse()); } } }