jdon当在获取service时报错,重启就好了

13-08-06 mianwo602

013-08-02 07:52:12,905 [http-80-exec-9] ERROR com.jdon.util.Debug - com.jdon.bussinessproxy.dyncproxy.DynamicProxyWeaving

java.lang.ArrayIndexOutOfBoundsException: 10

at java.util.ArrayList.indexOf(Unknown Source)

at java.util.ArrayList.contains(Unknown Source)

at com.jdon.aop.interceptor.PoolInterceptor.isPoolabe(PoolInterceptor.java:158)

at com.jdon.aop.interceptor.PoolInterceptor.invoke(PoolInterceptor.java:87)

at com.jdon.aop.reflection.ProxyMethodInvocation.proceed(ProxyMethodInvocation.java:84)

at com.jdon.aop.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:58)

at com.jdon.aop.reflection.ProxyMethodInvocation.proceed(ProxyMethodInvocation.java:84)

at com.jdon.aop.AopClient.invoke(AopClient.java:61)

at com.jdon.bussinessproxy.dyncproxy.DynamicProxyWeaving.invoke(DynamicProxyWeaving.java:62)

at $Proxy36.getT_memberModelListForm(Unknown Source)

at cn.vetech.framework.member.model.T_member_action.execute(T_member_action.java:474)

1
mianwo602
2013-08-06 11:31

我刚看了源码

PoolInterceptor

private List isPoolableCache = new ArrayList();

这个 public boolean isPoolabe(TargetMetaDef targetMetaDef) {

boolean found = false;

if (isPoolableCache.contains(targetMetaDef.getName())) {

found = true;

}else if(!unPoolableCache.contains(targetMetaDef.getName())){

Debug.logVerbose("[JdonFramework] check if it is a Poolable", module);

ContainerWrapper containerWrapper = containerCallback.getContainerWrapper();

Class thisCLass = containerWrapper.getComponentClass(targetMetaDef.getName());

if (Poolable.class.isAssignableFrom(thisCLass)) {

found = true;

isPoolableCache.add(targetMetaDef.getName());

}else{

unPoolableCache.add(targetMetaDef.getName());

}

}

return found;

}

isPoolableCache.contains这个和add在并发下会出现越界

contains里面实际上是调用的indexOf,这个是循环size通过下标访问数据进行比较。有可能会发生当前size是10个,这个时候我们在调用contains这个时,然后按照size是10循环小标,然后这个时候其他地方把数据删除一个,变成9,那么在循环到10的时候,那么就会越界。

我看到最新的版本和以前的版本都有这个问题,我现在把

private final List isPoolableCache = new CopyOnWriteArrayList();改成这样就好了。就没出现了