异常信息:
ERROR [task-2] org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler [handleUncaughtException#39] : Unexpected exception occurred invoking async method: public void org.cert.securityanalyzer.core.ScanEngine.run(java.util.List)
org.springframework.data.mongodb.UncategorizedMongoDbException: Interrupted acquiring a permit to retrieve an item from the pool ; nested exception is com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2783)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:546)
at org.springframework.data.mongodb.core.MongoTemplate.insertDocument(MongoTemplate.java:1433)
at org.springframework.data.mongodb.core.MongoTemplate.doInsert(MongoTemplate.java:1243)
伪代码如下
@Async
public void scan(List<File> files) {
files.foreach(f -> {
try{
scanSevice.scan(file);
file.setSuccess(true);
} catch (Exception e){
file.setSuccess(false);
}
mongoTemplate.insert(file);
})
Google 了许多,有的说是因为其他线程 interrupted 导致,参见这篇 jira,我所依赖方法是多线程的,引用别人的 jar,属于我这边不可控的,的确,看到引用那边如果它的多线程出了异常,我这 mongo 就插不进去,如果没错误的话就能插进去,但是这是 mongo 的坑吧,直接测试FilsUtils.writeStringToFile
是没问题的。
依赖的方法异常片段:
ERROR [Thread-74] heros.solver.CountingThreadPoolExecutor [afterExecute#64] : Worker thread execution failed: Opcode: IGET_BOOLEAN_QUICK @ 0x21
java.lang.IllegalArgumentException: Opcode: IGET_BOOLEAN_QUICK @ 0x21
at soot.dexpler.instructions.InstructionFactory.fromOpcode(InstructionFactory.java:381)
at soot.dexpler.instructions.InstructionFactory.fromInstruction(InstructionFactory.java:48)
at soot.dexpler.DexBody.extractDexInstructions(DexBody.java:242)
at soot.dexpler.DexBody.<init>(DexBody.java:208)
at soot.dexpler.DexMethod$1.getBody(DexMethod.java:118)
at soot.SootMethod.retrieveActiveBody(SootMethod.java:402)
at soot.PackManager$3.run(PackManager.java:1293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
已尝试的方法,但没用。。。
spring.data.mongodb.connectionTimeout
及 spring.data.mongodb.socketTimeout
(时间为半小时,通常 10-20 多分钟扫完)new Thread(() -> mongoTemplate.insert(file)).run()
但是遗憾还不行。。。 大佬们是否遇到过此类情况?或者有什么建议方法?尽量不改现有框架把。。
1
stephCurry OP |