Summary: | uncaptured exception make SocketProcessor container has a httpconnection leak | ||
---|---|---|---|
Product: | Tomcat 8 | Reporter: | newchaos <newchaos> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED INVALID | ||
Severity: | normal | ||
Priority: | P2 | ||
Version: | 8.5.23 | ||
Target Milestone: | ---- | ||
Hardware: | PC | ||
OS: | Linux | ||
Attachments: | the line 1476 encounter a exception |
If log.error("",t) throws an exception you have much bigger problems than a connection leak. Once things start to go that badly wrong, it is not practical to handle all possible errors. |
Created attachment 38104 [details] the line 1476 encounter a exception tomcat-embed-core-8.5.23.jar if org.apache.tomcat.util.net.NioEndpoint.SocketProcessor#doRun encounter exception before connection closed and it is not CancelledKeyException class,it will trigger throw exception to the third catch code block. if org.apache.tomcat.util.net.NioEndpoint.SocketProcessor#doRun (line 1453 -- line 1485) if (handshake == 0) { SocketState state = SocketState.OPEN; // Process the request from this socket if (event == null) { state = getHandler().process(socketWrapper, SocketEvent.OPEN_READ); } else { state = getHandler().process(socketWrapper, event); } if (state == SocketState.CLOSED) { close(socket, key); } } else if (handshake == -1 ) { close(socket, key); } else if (handshake == SelectionKey.OP_READ){ socketWrapper.registerReadInterest(); } else if (handshake == SelectionKey.OP_WRITE){ socketWrapper.registerWriteInterest(); } } catch (CancelledKeyException cx) { socket.getPoller().cancelledKey(key); } catch (VirtualMachineError vme) { ExceptionUtils.handleThrowable(vme); } catch (Throwable t) { log.error("", t); socket.getPoller().cancelledKey(key); } finally { socketWrapper = null; event = null; //return to cache if (running && !paused) { processorCache.push(this); } } and in the catch block if the first line code(line 1476) encounter exception, the second line code(line 1477) will be skip. and the socket will be not closed, ,and make a socket connection leak.