码迷,mamicode.com
首页 > 编程语言 > 详细

使用HashMap线程不安全造成CPU 100%

时间:2015-04-28 11:51:14      阅读:259      评论:0      收藏:0      [点我收藏+]

标签:

   最近应用服务器总时不时的报CPU 100%,是多个CPU 100%。最后查出是aspectjweaver这个jar包中用到了HashMap是线程不安全的。本次事故总结就是第三方jar包也要时刻关注。

<2015-4-25 下午08时12分44秒 CST> <Error> <WebLogicServer> <BEA-000337> <[STUCK] ExecuteThread: ‘13‘ for queue: ‘weblogic.kernel.Default (self-tuning)‘ has been busy for "657" seconds working on the request "weblogic.servlet.internal.ServletRequestImpl@49f969a[

POST /web/gg/workflow/fore/DoSpecialForeSubmit.jsp?isProgress=false HTTP/1.1
X-Forwarded-For: 10.124.19.6
Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://10.150.140.20/web/gg/material/workflow/fore/SelForePersons.jsp?pCount=1&pFlowKey=GMM_DataLabel_ForCSG&pAllFlag=false&pReturnURL=/web/gg/groupmaterial/audit/purchaseplan/CSGPurchasePlanAudit.jsp?pageNo=1|status=auditing|nodeString=null:null;GMM_DataLabel_ForCSG;000004|frameName=p_req_plan_window|labelType=20&pAdapterClass=CSGDataLabelForwardAdapter&pWorkFlowId=undefined&pAreaCode=undefined&pDisplayOpinionArea=false&pRequireOpinion=false&pShowRoleFilter=false&pFlag=undefined&pModulePath=gg/material&pSubmitCallback=loading()&pIsAsync=false&pIsProgress=undefined&pReadAllPage=undefined
Accept-Language: zh-CN
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; Mozilla/4.0(Compatible Mozilla/4.0(Compatible-EmbeddedWB 14.58 http://bsalsa.com/ EmbeddedWB- 14.58  from: http://bsalsa.com/ ; Mozilla/4.0(Compatible RogueCleanerEmbeddedWB- 14.58  from: http://bsalsa.com/ ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; BRI/2; Tablet PC 2.0; InfoPath.3)
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Content-Length: 792
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: 6E198C893C55D08419683DCDAA6E3463=07D9F9949578C1F56F881944EED7BF65; 6E198C893C55D084A63A0BBA80A8BB6C0379382D298AF80F=17D870ABAF8BB61086F2B509C258111A6A8D5FCAB9E3CB0E69E09E1EDECE27CB0379382D298AF80F; JSESSIONIDMINI=XdGCV7CFkqpvC2lhvxZg1ghmMBvfwnyzv7QLQGPGtSvgFlJSPvkL!-2010002315; JSESSIONIDIPMS=qnT2V7BTS1bnczD8VBXwGdX8xBgN451CLKrGKHsRnfkNM5P12RDQ!1786716604; ComtopSessionSID=<SNAID>gS9YV7BYzjN3TnFYHht3F8Tvhj7ZMZxc4ntSnc1vBTGcVDnLh9QL!64005734!1429963256371</SNAID>

]", which is more than the configured time (StuckThreadMaxTime) of "600" seconds. Stack trace:
java.util.WeakHashMap.getEntry(WeakHashMap.java:383)
java.util.WeakHashMap.containsKey(WeakHashMap.java:369)
com.bea.core.repackaged.aspectj.lang.reflect.AjTypeSystem.getAjType(AjTypeSystem.java:37)

com.bea.core.repackaged.springframework.aop.aspectj.annotation.AbstractAspectJAdvisorFactory.isAspect(AbstractAspectJAdvisorFactory.java:113)
com.bea.core.repackaged.springframework.aop.aspectj.annotation.BeanFactoryAspectJAdvisorsBuilder.buildAspectJAdvisors(BeanFactoryAspectJAdvisorsBuilder.java:95)
com.bea.core.repackaged.springframework.jee.intercept.InterceptionMetadata.addAspectJAdvisors(InterceptionMetadata.java:835)
com.bea.core.repackaged.springframework.jee.intercept.InterceptionMetadata.createProxyIfNecessary(InterceptionMetadata.java:477)
com.bea.core.repackaged.springframework.jee.intercept.InterceptionMetadata.createProxyIfNecessary(InterceptionMetadata.java:410)
com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBrokerImpl.invokeCreateProxyIfNecessary(EjbComponentCreatorBrokerImpl.java:97)
com.bea.core.repackaged.springframework.jee.spi.EjbComponentCreatorBrokerImpl.getBean(EjbComponentCreatorBrokerImpl.java:53)
weblogic.ejb.container.injection.EjbComponentCreatorImpl.getBean(EjbComponentCreatorImpl.java:67)
weblogic.ejb.container.manager.BaseEJBManager.createNewBeanInstance(BaseEJBManager.java:216)
weblogic.ejb.container.manager.BaseEJBManager.allocateBean(BaseEJBManager.java:233)
weblogic.ejb.container.manager.StatelessManager.createBean(StatelessManager.java:303)
weblogic.ejb.container.pool.StatelessSessionPool.createBean(StatelessSessionPool.java:190)
weblogic.ejb.container.pool.StatelessSessionPool.getBean(StatelessSessionPool.java:121)
weblogic.ejb.container.manager.StatelessManager.preInvoke(StatelessManager.java:148)
weblogic.ejb.container.internal.BaseRemoteObject.preInvoke(BaseRemoteObject.java:227)
weblogic.ejb.container.internal.StatelessRemoteObject.preInvoke(StatelessRemoteObject.java:52)
com.gg.masterdata.objecttrack.appservice.impl.ObjectTrackSes_gtdbkl_IObjectTrackServiceImpl.processingTrackRecord(ObjectTrackSes_gtdbkl_IObjectTrackServiceImpl.java:899)
com.gg.masterdata.objecttrack.appservice.impl.ObjectTrackSes_gtdbkl_IObjectTrackServiceImpl_CBV.processingTrackRecord(Unknown Source)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


com.bea.core.repackaged.aspectj.aspectjweaver_5.1.0.jar
package com.bea.core.repackaged.aspectj.lang.reflect;
import com.bea.core.repackaged.aspectj.internal.lang.reflect.AjTypeImpl;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.WeakHashMap;
public class AjTypeSystem {
private static Map<Class, WeakReference<AjType>> ajTypes = new WeakHashMap();
public static <T> AjType<T> getAjType(Class<T> fromClass) {
if (ajTypes.containsKey(fromClass)) {
WeakReference weakRefToAjType = (WeakReference) ajTypes
.get(fromClass);
AjType theAjType = (AjType) weakRefToAjType.get();
if (theAjType != null) {
return theAjType;
}
theAjType = new AjTypeImpl(fromClass);
ajTypes.put(fromClass, new WeakReference(theAjType));
return theAjType;
}

AjType theAjType = new AjTypeImpl(fromClass);
ajTypes.put(fromClass, new WeakReference(theAjType));
return theAjType;
}
}


com.bea.core.repackaged.aspectj.aspectjweaver_5.3.0.jar
package com.bea.core.repackaged.aspectj.lang.reflect;
import com.bea.core.repackaged.aspectj.internal.lang.reflect.AjTypeImpl;
import java.lang.ref.WeakReference;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
public class AjTypeSystem {
private static Map<Class, WeakReference<AjType>> ajTypes = Collections
.synchronizedMap(new WeakHashMap());



public static <T> AjType<T> getAjType(Class<T> paramClass) {
WeakReference localWeakReference = (WeakReference) ajTypes
.get(paramClass);
if (localWeakReference != null) {
localObject = (AjType) localWeakReference.get();
if (localObject != null)
return localObject;
localObject = new AjTypeImpl(paramClass);
ajTypes.put(paramClass, new WeakReference(localObject));
return localObject;
}
Object localObject = new AjTypeImpl(paramClass);
ajTypes.put(paramClass, new WeakReference(localObject));
return ((AjType<T>) localObject);
}
}

使用HashMap线程不安全造成CPU 100%

标签:

原文地址:http://blog.csdn.net/stevendbaguo/article/details/45332301

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!