[jboss-jira] [JBoss JIRA] Commented: (JBAS-3216) PooledInvokerProxy.getPooledConnection() is not threadsafe

Ola Bini (JIRA) jira-events at jboss.com
Thu Jan 25 10:23:02 EST 2007


    [ http://jira.jboss.com/jira/browse/JBAS-3216?page=comments#action_12351637 ] 
            
Ola Bini commented on JBAS-3216:
--------------------------------

This bug is not fixed in any of the versions abovementioned. It is a serious showstopper and need to be fixed for the next version. This bug should be reopened.

> PooledInvokerProxy.getPooledConnection() is not threadsafe
> ----------------------------------------------------------
>
>                 Key: JBAS-3216
>                 URL: http://jira.jboss.com/jira/browse/JBAS-3216
>             Project: JBoss Application Server
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Remoting
>    Affects Versions: JBossAS-4.0.4RC1, JBossAS-4.0.3 SP1
>            Reporter: Anders Welen
>         Assigned To: Scott M Stark
>             Fix For: JBossAS-5.0.0.Beta1, JBossAS-4.0.5.CR1
>
>
> Code from 4.0.3SP1
> =================
>    protected ClientSocket getPooledConnection()
>    {
>       ClientSocket socket = null;
>       while (pool.size() > 0)
>       {
>          socket = (ClientSocket)pool.removeFirst();
>          try
>          {
>             // Test to see if socket is alive by send ACK message
>             final byte ACK = 1;
>             socket.out.writeByte(ACK);
>             socket.out.flush();
>             socket.in.readByte();
>             return socket;
>          }
>          catch (Exception ex)
>          {
>             try
>             {
>                socket.socket.close();
>             }
>             catch (Exception ignored) {}
>          }
>       }
>       return null;
>    }
> ===========================
> Should be changed to:
>    protected ClientSocket getPooledConnection()
>    {
>       ClientSocket socket = null;
> synchronized (pool) {
>       while (pool.size() > 0)
>       {
>          socket = (ClientSocket)pool.removeFirst();
>          try
>          {
>             // Test to see if socket is alive by send ACK message
>             final byte ACK = 1;
>             socket.out.writeByte(ACK);
>             socket.out.flush();
>             socket.in.readByte();
>             return socket;
>          }
>          catch (Exception ex)
>          {
>             try
>             {
>                socket.socket.close();
>             }
>             catch (Exception ignored) {}
>          }
>       }
> }
>       return null;
>    }
> ===========================
> ....or perhaps better:
>    protected ClientSocket getPooledConnection()
>    {
>       ClientSocket socket = null;
>       while (pool.size() > 0)
>       {
>          try {
>            socket = (ClientSocket)pool.removeFirst();
>          }
>          catch (java.util.NoSuchElementException nsee)
>          {
>               return null;
>          }
>          try
>          {
>             // Test to see if socket is alive by send ACK message
>             final byte ACK = 1;
>             socket.out.writeByte(ACK);
>             socket.out.flush();
>             socket.in.readByte();
>             return socket;
>          }
>          catch (Exception ex)
>          {
>             try
>             {
>                socket.socket.close();
>             }
>             catch (Exception ignored) {}
>          }
>       }
>       return null;
>    }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list