<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
<table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tbody>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tbody>
<tr>
<td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
<h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
<!-- To have a header image/logo replace the name below with your img tag -->
<!-- Email clients will render the images when the message is read so any image -->
<!-- must be made available on a public server, so that all recipients can load the image. -->
<a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
</td>
</tr>
<tr>
<td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Re: PingTimerTask in JBoss AS 5.0.1.GA EAP
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/kevin.lohmann">Kevin Lohmann</a> in <i>JBoss Remoting</i> - <a href="http://community.jboss.org/message/560203#560203">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hi there again,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I've created a simple standalone-client-scenario to reproduce the above warnings:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">public class TestScenario {
    // ############### CONFIG #################
    private final static String sJMS_CONNECTION_FACTORY_NAME = "ClusteredConnectionFactory";
    private final static int sCONCURRENT_CALLS = 25;
    private final static long sSLEEP_TIME = sCONCURRENT_CALLS * 100;
    // ########################################
   
    private final static CountDownLatch sCDL = new CountDownLatch(sCONCURRENT_CALLS);
    private final static SimpleDateFormat sDATE_FORMATER = new SimpleDateFormat("HH:mm:ss.SSS ");
   
    public static void main(String[] args) {
        for (int i = 0; i < sCONCURRENT_CALLS; i++) {
            final int lIteration = i;
            Thread lThread = new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        doIteration();
                    } catch (Throwable t) {
                        t.printStackTrace();
                    }
                }
            }, "Thread-no." + lIteration);
            lThread.setDaemon(true);
            lThread.start();
        }
        try {
            Thread.sleep(sSLEEP_TIME);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log("...ready!");
       
    }
    /**
     * @throws NamingException
     */
    private static void doIteration() throws NamingException {
        log("...lookup JMSConnectionFactory...");
        ConnectionFactory lConnectionFactory = lookUpJMSConnectionFactory();
        sCDL.countDown();
       
        Connection lConnection;
        try {
            log("...create JMSConnection...");
            lConnection = lConnectionFactory.createConnection();
            log("...close JMSConnection...");
            lConnection.close();
        } catch (JMSException e) {
            e.printStackTrace();
        }
        log("...ready!");
    }
    /**
     * @return
     * @throws NamingException
     */
    private static ConnectionFactory lookUpJMSConnectionFactory() throws NamingException {
        Context lContext = new InitialContext();
        return (ConnectionFactory) lContext.lookup(sJMS_CONNECTION_FACTORY_NAME);
    }
    private static void log(String pLog) {
        System.out.println(sDATE_FORMATER.format(new Date()) + Thread.currentThread().getName() + pLog);
    }
   
}</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This will create <em>${sCONCURRENT_CALLS}</em> daemon threads. Each thread gets a jms connectionfactory, creates a connection and closes the connection. The main thread will sleep <em>${sSLEEP_TIME}</em> milli seconds before terminating.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>With the above config, I receive everytime the following ConcurrentModificationException within the client:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">Exception in thread "Thread-1" java.util.ConcurrentModificationException
    at java.util.WeakHashMap$HashIterator.nextEntry(WeakHashMap.java:762)
    at java.util.WeakHashMap$KeyIterator.next(WeakHashMap.java:795)
    at org.jboss.jms.client.delegate.ClientClusteredConnectionFactoryDelegate$FinalizerShutdownHook.run(ClientClusteredConnectionFactoryDelegate.java:462)</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>In server.log the following can be seen:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">2010-09-02 11:57:05,510 WARN  [org.jboss.remoting.transport.bisocket.BisocketClientInvoker] (Timer-4) Unable to send ping: shutting down PingTimerTask
java.net.SocketException: Connection reset by peer: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at org.jboss.remoting.transport.bisocket.BisocketClientInvoker$PingTimerTask.run(BisocketClientInvoker.java:723)
    at java.util.TimerThread.mainLoop(Unknown Source)
    at java.util.TimerThread.run(Unknown Source)
And:
2010-09-02 11:56:59,401 ERROR [org.jboss.remoting.transport.socket.ServerThread] (WorkerThread#40[10.3.4.124:4488]) WorkerThread#40[10.3.4.124:4488] failed
java.io.IOException: Connection reset by peer: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
    at java.io.BufferedOutputStream.flush(Unknown Source)
    at java.io.DataOutputStream.flush(Unknown Source)
    at org.jboss.jms.wireformat.NullResponse.write(NullResponse.java:53)
    at org.jboss.jms.wireformat.JMSWireFormat.write(JMSWireFormat.java:237)
    at org.jboss.remoting.transport.socket.ServerThread.versionedWrite(ServerThread.java:1051)
    at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:807)
    at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:721)
    at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:575)
    at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:234)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I assume, these warnings and errors occur because the clients brake away. Can anyone confirm this?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks,</p><p> Kevin</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/560203#560203">going to Community</a></p>
<p style="margin: 0;">Start a new discussion in JBoss Remoting at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2050">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>