We have this code
in 
org.apache.logging.log4j.core.net.TcpSocketManager.TcpSocketManagerFactory.createManager(String,
FactoryData):

        @Override
        public TcpSocketManager createManager(final String name, final
FactoryData data) {

            InetAddress inetAddress;
            OutputStream os;
            try {
                inetAddress = InetAddress.getByName(data.host);
            } catch (final UnknownHostException ex) {
                LOGGER.error("Could not find address of " + data.host, ex,
ex);
                return null;
            }
            try {
                // LOG4J2-1042
                final Socket socket = new Socket();
                socket.connect(new InetSocketAddress(data.host, data.port),
data.connectTimeoutMillis);
                os = socket.getOutputStream();
                return new TcpSocketManager(name, os, socket, inetAddress,
data.host, data.port,
                        data.connectTimeoutMillis, data.delayMillis,
data.immediateFail, data.layout);
            } catch (final IOException ex) {
                LOGGER.error("TcpSocketManager (" + name + ") " + ex, ex);
                os = new ByteArrayOutputStream();
            }
            if (data.delayMillis == 0) {
                return null;
            }
            return new TcpSocketManager(name, os, null, inetAddress,
data.host, data.port, data.connectTimeoutMillis,
                    data.delayMillis, data.immediateFail, data.layout);
        }

Notice:

                LOGGER.error("TcpSocketManager (" + name + ") " + ex, ex);
                os = new ByteArrayOutputStream();

What is the point of that? It creates an unbound stream in RAM, creating
one problem while dealing with another.

I think it would be better to not create the manager at all.

Thoughts?

Gary

-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to