You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@TestpublicvoidtestParserInterruptedByTimeout() {
MemoryLeakVerifierverifier = newMemoryLeakVerifier();
intparallelThreads = Runtime.getRuntime().availableProcessors() + 1;
ExecutorServiceexecutorService = Executors.newFixedThreadPool(parallelThreads);
ExecutorServicetimeOutService = Executors.newSingleThreadExecutor();
for (inti = 0; i < parallelThreads; i++) {
executorService.submit(newRunnable() {
@Overridepublicvoidrun() {
try {
CCJSqlParserparser =
CCJSqlParserUtil.newParser(INVALID_SQL)
.withAllowComplexParsing(true);
verifier.addObject(parser);
CCJSqlParserUtil.parseStatement(parser, timeOutService);
} catch (JSQLParserExceptionignore) {
// We expected that to happen.
}
}
});
}
timeOutService.shutdownNow();
executorService.shutdown();
// we should not run in any timeout here (because we expect that the Parser has timed out by// itself)assertDoesNotThrow(newExecutable() {
@Overridepublicvoidexecute() throwsThrowable {
executorService.awaitTermination(20, TimeUnit.SECONDS);
}
});
// we should not have any Objects left in the weak reference mapverifier.assertGarbageCollected();
}
每次调这个parse方法时候,他里面就创建一个单线程的线程池,然后同步解析,之后就销毁线程,目的就为了加一个8秒超时抛异常的逻辑。。。我并发请求分页接口,服务的线程数直接飙升了200个,简直了,而且最后这个feature.get还全都8秒超时抛异常!
而且...为毛它会存在8秒都解析不完的情况啊,这究竟是什么性能...
The text was updated successfully, but these errors were encountered: