问题现象:
java.lang.Thread.State: BLOCKED (on object monitor)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:719)
- waiting to lock <0x0000000080af2208> (a sun.net.www.protocol.jar.URLJarFile)
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at java.io.DataInputStream.read(DataInputStream.java:100)
at com.sun.xml.internal.bind.v2.bytecode.ClassTailor.tailor(ClassTailor.java:176)
at com.sun.xml.internal.bind.v2.runtime.reflect.opt.AccessorInjector.tailor(AccessorInjector.java:107)
at com.sun.xml.internal.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:68)
....
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:462)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
解决:
JAXBContextImpl#newInstance(Class clazz)方法内存在synchronized修饰的io流,属于线程安全,多个线程获取JAXBContext对象时会阻塞
使用单例模式代替JAXBContext.newInstance创建JAXBContext对象
1.问题:
夜间批量cpu100%,查看日志发现bean转xml工具类耗时较长
关键日志:
2021-05-21 02:20:11.168 [SOFA-SEV-BOLT-BIZ-12200-13-T40] INFO [TarceId:0b080b8d1621534806127496822] com...utils...ESBUtils - request soaRequest {transId:xxx}:SoaRequest{name='FindRequest', xmlns='http://localhost:9001/app100/proxyService/inquery/origiTransInqeury/xxx500_v1_0_0_proxy', params={requestHeader={HD_Init_Ext_TX_Cd=019E, HD_Termn_Typ=99, HD_Chnl_Seq_Num=123, HD_Chrg_Fine_Item_Cnt=0, HD_Free_Amt=0.00}, requestBody={Cust_Acct_Num=111}}}
2021-05-21 02:20:15.157 [SOFA-SEV-BOLT-BIZ-12200-13-T40] INFO [TarceId:0b080b8d1621534806127496822] com....utils...ESBUtils - bean--Xml = :3989ms
2021-05-21 02:20:15.236 [SOFA-SEV-BOLT-BIZ-12200-13-T40] INFO com...utils...ESBUtils - request time:79ms
2021-05-21 02:20:15.237 [SOFA-SEV-BOLT-BIZ-12200-13-T40] INFO [TarceId:0b080b8d1621534806127496822] com...utils...ESBUtils - Xml--bean = :1ms
2021-05-21 02:20:15.237 [SOFA-SEV-BOLT-BIZ-12200-13-T40] INFO [TarceId:0b080b8d1621534806127496822] com...utils...ESBUtils - totRunTime:4069ms