chenggwang commented on PR #671:
URL: https://github.com/apache/tomcat/pull/671#issuecomment-1755822815

   `protected boolean setSocketOptions(SocketChannel socket) {
           NioSocketWrapper socketWrapper = null;
           try {
               // Allocate channel and wrapper
               NioChannel channel = null;
               if (nioChannels != null) {
                   channel = nioChannels.pop();
               }
               if (channel == null) {
                   SocketBufferHandler bufhandler = new SocketBufferHandler(
                           socketProperties.getAppReadBufSize(),
                           socketProperties.getAppWriteBufSize(),
                           socketProperties.getDirectBuffer());
                   channel = createChannel(bufhandler);
               }
               NioSocketWrapper newWrapper = new NioSocketWrapper(channel, 
this);
               channel.reset(socket, newWrapper);
               connections.put(socket, newWrapper);
               socketWrapper = newWrapper;`
   Because it is not until `channel.reset(socket, newWrapper); `is executed. sc 
and socketWrapper will not be assigned values. But if toString() is called 
before (e.g., channel, socketWrapper in IDEA breakpoint debugging), a null 
pointer exception is thrown.
   <img width="824" alt="bug 2023-10-10 231457" 
src="https://github.com/apache/tomcat/assets/90715678/a3d77ce8-74a2-46b1-aee7-f2a3cf6c2ade";>
   
   


-- 
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: dev-unsubscr...@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to