Hello:

I am getting intermittent (rare, but causing fatal shutdown) exceptions when pinging NetworkServerControl:

2010-08-02 15:31:25,491 [ApacheDerbyServer] INFO  components.DerbyServerComponent  - 2010-08-02 19:31:25.491 GMT : Error on client socket:Socket closed
2010-08-02 15:31:25,492 [ApacheDerbyServer] INFO  components.DerbyServerComponent  - 2010-08-02 19:31:25.492 GMT : Socket closed
2010-08-02 15:31:25,492 [ApacheDerbyServer] INFO  components.DerbyServerComponent  - java.net.SocketException: Socket closed
2010-08-02 15:31:25,492 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at java.net.SocketInputStream.socketRead0(Native Method)
2010-08-02 15:31:25,493 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at java.net.SocketInputStream.read(SocketInputStream.java:129)
2010-08-02 15:31:25,493 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at java.net.SocketInputStream.read(SocketInputStream.java:90)
2010-08-02 15:31:25,493 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at org.apache.derby.impl.drda.NetworkServerControlImpl.fillReplyBuffer(Unknown Source)
2010-08-02 15:31:25,494 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at org.apache.derby.impl.drda.NetworkServerControlImpl.readResult(Unknown Source)
2010-08-02 15:31:25,494 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at org.apache.derby.impl.drda.NetworkServerControlImpl.pingWithNoOpen(Unknown Source)
2010-08-02 15:31:25,494 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at org.apache.derby.impl.drda.NetworkServerControlImpl.ping(Unknown Source)
2010-08-02 15:31:25,495 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at org.apache.derby.drda.NetworkServerControl.ping(Unknown Source)
2010-08-02 15:31:25,495 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at com.jefco.fi.geni.components.DerbyServerComponent.run(DerbyServerComponent.java:142)
2010-08-02 15:31:25,495 [ApacheDerbyServer] INFO  components.DerbyServerComponent  -    at java.lang.Thread.run(Thread.java:619)
2010-08-02 15:31:25,496 [ApacheDerbyServer] ERROR components.DerbyServerComponent  - Error while pinging NetworkServerControl:
java.net.SocketException: Socket closed
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(SocketInputStream.java:129)
        at java.net.SocketInputStream.read(SocketInputStream.java:90)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.fillReplyBuffer(Unknown Source)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.readResult(Unknown Source)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.pingWithNoOpen(Unknown Source)
        at org.apache.derby.impl.drda.NetworkServerControlImpl.ping(Unknown Source)
        at org.apache.derby.drda.NetworkServerControl.ping(Unknown Source)

My code pings the NSC in two places - there is one thread which implements run() method like this:

final public void run() {
        final Thread currentThread = Thread.currentThread();

        try {
            m_server = new NetworkServerControl(m_host, m_port);
            m_server.start(new PrintWriter(new LoggingOutputStream(logger, Level.INFO), true));

            try {
                while (m_thread == currentThread) {
                    try {
                        Thread.sleep(m_sleep);

                        if (logger.isTraceEnabled()) {
                            logger.trace("Pinging NetworkServerControl on [" + m_host + ":" + m_port + "]");
                        }

--->                        m_server.ping();   <--- Exception Thrown
                    } catch (InterruptedException e) {
                        logger.info(toString() + " sleep has been interrupted");
                    }
                }
            } catch (Exception e) {
                logger.error("Error while pinging NetworkServerControl:", e);
            }

            logger.info("Stopping NetworkServerControl on [" + m_host + ":" + m_port + "]");
            m_server.shutdown();
        } catch (Exception e) {
            logger.error("Error while starting/stopping NetworkServerControl:", e);
        }
    }

And another "validating" thread calls this method at regular intervals:

    final public String isRuntimeValid() {
        final StringBuilder builder = new StringBuilder();
        builder.append(super.isRuntimeValid());

        if (m_server == null) builder.append("\n\t").append("Server is null");
        if (m_thread == null) builder.append("\n\t").append("Thread is null");

        try {
            m_server.ping();
        } catch (Exception e) {
            builder.append("\n\t").append("Server cannot be pinged");
        }

        return builder.toString();
    }

Can there be any problem if those two are called at around the same time? This is probably the only scenario which could, I imagine, cause a problem...
Would anyone have any other thoughts or suspicions?

Much appreciated,

Pavel.



Jefferies archives and monitors outgoing and incoming e-mail. The contents of this email, including any attachments, are confidential to the ordinary user of the email address to which it was addressed. If you are not the addressee of this email you may not copy, forward, disclose or otherwise use it or any part of it in any form whatsoever. This email may be produced at the request of regulators or in connection with civil litigation. Jefferies accepts no liability for any errors or omissions arising as a result of transmission. Use by other than intended recipients is prohibited.  In the United Kingdom, Jefferies operates as Jefferies International Limited; registered in England: no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London EC4V 3BJ.  Jefferies International Limited is authorised and regulated by the Financial Services Authority.