-
Bug
-
Resolution: Done
-
Major
-
JBossAS-4.0.3 SP1, JBossAS-4.0.4RC1
-
None
-
Low
Code from 4.0.3SP1
=================
protected ClientSocket getPooledConnection()
{
ClientSocket socket = null;
while (pool.size() > 0)
{
socket = (ClientSocket)pool.removeFirst();
try
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
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;
}