views:

149

answers:

1

When running my embedded jetty web app launcher, I see the following output to stderr. I just started seeing this after moving my build to maven-2. Has anyone seen this before?

IDLE SCEP@988057 [d=false,io=1,w=true,rb=false,wb=false],NOT_HANDSHAKING, in/out=0/0 Status = OK HandshakeStatus = NOT_HANDSHAKING
bytesConsumed = 5469 bytesProduced = 5509

It repeats occasionally seemingly at random times.

A: 

This seems to be coming from jetty NIO support -- it appears that jetty feels it is appropriate to log to stderr when it close idle connections.

at org.eclipse.jetty.io.nio.SelectChannelEndPoint.checkIdleTimestamp(SelectChannelEndPoint.java:231)
at org.eclipse.jetty.io.nio.SelectorManager$SelectSet$2.run(SelectorManager.java:768)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:436)

For those with similar problems, I overrode System.err with a mock output stream:

public class DebugOutputStream extends OutputStream {
    private Logger s_logger = LoggerFactory.getLogger(DebugOutputStream.class);

    private final OutputStream m_realStream;
    private ByteArrayOutputStream baos = new ByteArrayOutputStream();
    private Pattern m_searchFor;

    public DebugOutputStream(OutputStream realStream, String regex) {
        m_realStream = realStream;
        m_searchFor = Pattern.compile(regex);
    }

    public void write(int b) throws IOException {
        baos.write(b);
        if (m_searchFor.matcher(baos.toString()).matches()) {
            s_logger.info("unwanted output detected", new RuntimeException());
        }
        if (b == '\n') baos.reset();
        m_realStream.write(b);
    }
}
Justin