[ 
https://issues.apache.org/jira/browse/LOG4J2-1922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16113026#comment-16113026
 ] 

Gary Gregory commented on LOG4J2-1922:
--------------------------------------

You can run it from the command line with {{--help}}:

{noformat}
Usage: org.apache.logging.log4j.server.TcpSocketServer [options]
  Options:
    --backlog, -b
       Server socket backlog.
       Default: 50
    --classes, -C
       Additional classes to allow deserialization
    --config, -c
       Log4j configuration file location (path or URL).
    --help, -?, -h
       Prints this help.
       Default: false
    --interactive, -i
       Accepts commands on standard input ("exit" is the only command).
       Default: false
    --localbindaddress, -a
       Server socket local bind address.
    --port, -p
       Server socket port.
       Default: 0
{noformat}

> 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.3
>            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)

Reply via email to