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;