JBoss Remoting 2.2.2里的一个Bug
作者:网络转载 发布时间:[ 2014/12/17 15:09:47 ] 推荐标签:软件测试 缺陷管理
在JBoss Remoting 2.2.2中存在这么一个bug,如果刚好客户端的timeout比服务器端处理时间短的话,会出现客户端连接池中的连接被无故用掉一个的状况,而且是没法回收的,终会导致很快客户端的连接池被占满的现象,在分析JBoss Remoting 2.2.2的代码后发现了问题的所在,同时查看了下JBoss Remoting 2.4的代码,发现在2.4中此bug已被修复。
来看下JBoss Remoting 2.2.2中有问题的这段代码的片断:
synchronized(usedPoolLock)
{
if (pooled != null)
{
usedPooled++;
if (trace) log.trace(this + " got a socket, usedPooled: " + usedPooled);
break;
}
if (usedPooled < maxPoolSize)
{
// Try to get a socket.
if (trace) log.trace(this + " getting a socket, usedPooled: " + usedPooled);
usedPooled++;
}
else
{
retry = true;
if (trace) log.trace(this + " will try again to get a socket");
}
}
Socket socket = null;
long timestamp = System.currentTimeMillis();
try
{
if (trace) { log.trace(this + " creating socket " + (counter++) + ", attempt " + (i + 1)); }
socket = createSocket(address.address, address.port, timeRemaining);
if (trace) log.trace(this + " created socket: " + socket);
}
catch (Exception ex)
{
log.debug(this + " got Exception " + ex + ", creation attempt took " +
(System.currentTimeMillis() - timestamp) + " ms");
synchronized(usedPoolLock)
{
usedPooled--;
}
if (i + 1 < numberOfRetries)
{
Thread.sleep(1);
continue;
}
throw ex;
}
socket.setTcpNoDelay(address.enableTcpNoDelay);
Map metadata = getLocator().getParameters();
if (metadata == null)
{
metadata = new HashMap(2);
}
else
{
metadata = new HashMap(metadata);
}
metadata.put(SocketWrapper.MARSHALLER, marshaller);
metadata.put(SocketWrapper.UNMARSHALLER, unmarshaller);
if (timeAllowed > 0)
{
timeRemaining = (int) (timeAllowed - (System.currentTimeMillis() - start));
if (timeRemaining <= 0)
break;
metadata.put(SocketWrapper.TEMP_TIMEOUT, new Integer(timeRemaining));
}
pooled = createClientSocket(socket, address.timeout, metadata);
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11