diff --git a/src/main/java/io/lettuce/core/internal/AsyncConnectionProvider.java b/src/main/java/io/lettuce/core/internal/AsyncConnectionProvider.java index 8d573a98e4..73457603ae 100644 --- a/src/main/java/io/lettuce/core/internal/AsyncConnectionProvider.java +++ b/src/main/java/io/lettuce/core/internal/AsyncConnectionProvider.java @@ -187,7 +187,14 @@ public void close(K key) { * @param action the action. */ public void forEach(Consumer action) { - connections.values().forEach(sync -> sync.doWithConnection(action)); + + LettuceAssert.notNull(action, "Action must not be null!"); + + connections.values().forEach(sync -> { + if (sync != null) { + sync.doWithConnection(action); + } + }); } /**