从码头到stderr的神秘控制台输出?

时间:2010-09-15 19:19:08

标签: jetty stderr embedded-jetty

运行我的嵌入式jetty Web应用程序启动器时,我看到以下输出到stderr。在将构建移动到maven-2之后,我才开始看到这一点。有没有人见过这个?

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

它偶尔会在随机时间重复出现。

1 个答案:

答案 0 :(得分:2)

这似乎来自于码头NIO的支持 - 看来码头认为在关闭空闲连接时登录到stderr是合适的。

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)

对于那些有类似问题的人,我用模拟输出流覆盖了System.err:

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);
    }
}