[ https://issues.apache.org/jira/browse/LOG4J2-1922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16112272#comment-16112272 ]
Kohei Tamura commented on LOG4J2-1922: -------------------------------------- Please tell me how to start TcpSocketServer 2.9-SNAPSHOT. > SocketHandler leaks connection if EOFException is thrown > -------------------------------------------------------- > > Key: LOG4J2-1922 > URL: https://issues.apache.org/jira/browse/LOG4J2-1922 > Project: Log4j 2 > Issue Type: Bug > Components: Core > Affects Versions: 2.7 > Reporter: Kohei Tamura > > SocketHandler should close the input stream in the finally block. > {code:title=TcpSocketServer.java|borderStyle=solid} > /** > * Thread that processes the events. > */ > private class SocketHandler extends Thread { > private final T inputStream; > private volatile boolean shutdown = false; > public SocketHandler(final Socket socket) throws IOException { > this.inputStream = > logEventInput.wrapStream(socket.getInputStream()); > } > @Override > public void run() { > boolean closed = false; > try { > try { > while (!shutdown) { > logEventInput.logEvents(inputStream, > TcpSocketServer.this); > } > } catch (final EOFException e) { > closed = true; > } catch (final OptionalDataException e) { > logger.error("OptionalDataException eof=" + e.eof + " > length=" + e.length, e); > } catch (final IOException e) { > logger.error("IOException encountered while reading from > socket", e); > } > if (!closed) { > try { > inputStream.close(); > } catch (final Exception ex) { > // Ignore the exception; > } > } > } finally { > handlers.remove(Long.valueOf(getId())); > } > } > public void shutdown() { > this.shutdown = true; > interrupt(); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)