[ https://issues.apache.org/jira/browse/LOG4J2-1922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16105847#comment-16105847 ]
Gary Gregory commented on LOG4J2-1922: -------------------------------------- Hi, Can you see if [LOG4J-1994|https://issues.apache.org/jira/browse/LOG4J2-1994] fixes this issue for you? The class is packaged in a different jar in 2.9-SNAPSHOT: https://repository.apache.org/content/repositories/snapshots/org/apache/logging/log4j/log4j-server/2.9-SNAPSHOT/ Thank you, Gary > 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)