KamToHung opened a new issue, #11357: URL: https://github.com/apache/dubbo/issues/11357
<!-- If you need to report a security issue please visit https://github.com/apache/dubbo/security/policy --> - [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate. ### Environment * Dubbo version: 3.2 * Operating System version: macOS Big Sur * Java version: 8 ### Steps to reproduce this issue 1. simple test ```java public class NPETest { protected WorldHandler handler = new WorldHandler(); @Test void handlerIsNull() throws RemotingException { Exchangers.bind("",null, handler); } } ``` 2. handler is not null in this step ```java public ChannelHandlerDispatcher(ChannelHandler... handlers) { this(handlers == null ? null : Arrays.asList(handlers)); } ``` 3. channelHandlers will add a null handler ```java public ChannelHandlerDispatcher(Collection<ChannelHandler> handlers) { if (CollectionUtils.isNotEmpty(handlers)) { this.channelHandlers.addAll(handlers); } } ``` 4. connected, disconnected, sent and caught method will NPE ### Expected Behavior channelHandlers have no null object ### Actual Behavior channelHandlers have null object ### reason ```java public ChannelHandlerDispatcher(ChannelHandler... handlers) { this(handlers == null ? null : Arrays.asList(handlers)); } public ChannelHandlerDispatcher(Collection<ChannelHandler> handlers) { if (CollectionUtils.isNotEmpty(handlers)) { this.channelHandlers.addAll(handlers); } } ``` if handlers is null, it will cast to ChannelHandler and use the first method then handlers is not null we can filter the null object when add to channelHandlers Can I fix it? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org