From 9e208c85740dfa5035c29ba84a419ff94b9ee519 Mon Sep 17 00:00:00 2001 From: Roman Kvasnytskyi Date: Thu, 18 Jan 2024 10:26:23 +0100 Subject: [PATCH] =?UTF-8?q?=C2=A0Fix=20Netty=20addListener=20instrumentati?= =?UTF-8?q?on=20=20(#10254)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../instrumentation/netty/v4/common/FutureListenerWrappers.java | 2 +- .../netty/v4/common/NettyFutureInstrumentation.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/FutureListenerWrappers.java b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/FutureListenerWrappers.java index 3f0d3f764e3d..b1a7e6eb24c4 100644 --- a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/FutureListenerWrappers.java +++ b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/FutureListenerWrappers.java @@ -43,7 +43,7 @@ protected Boolean computeValue(Class type) { }; public static boolean shouldWrap(GenericFutureListener> listener) { - return shouldWrap.get(listener.getClass()); + return listener != null && shouldWrap.get(listener.getClass()); } @SuppressWarnings("unchecked") diff --git a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/NettyFutureInstrumentation.java b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/NettyFutureInstrumentation.java index 2948fd77b656..49a0b86756bf 100644 --- a/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/NettyFutureInstrumentation.java +++ b/instrumentation/netty/netty-4-common/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4/common/NettyFutureInstrumentation.java @@ -82,6 +82,8 @@ public static void wrapListener( for (int i = 0; i < listeners.length; ++i) { if (FutureListenerWrappers.shouldWrap(listeners[i])) { wrappedListeners[i] = FutureListenerWrappers.wrap(context, listeners[i]); + } else { + wrappedListeners[i] = listeners[i]; } } listeners = wrappedListeners;