jsqlparser 4.5 library creates new temporary thread every time when parse statement

83 Views Asked by At

I talk about method net.sf.jsqlparser.parser.CCJSqlParserUtil#parseStatement.
Body of it method in library version 4.1 :

try {
    return parser.Statements();
} catch (Exception var2) {
    throw new JSQLParserException(var2);
}

Body of it method in library version 4.5 :

Statements statements = null;
try {
    ExecutorService executorService = Executors.newSingleThreadExecutor();
    Future<Statements> future = executorService.submit(new Callable<Statements>() {
        @Override
        public Statements call() throws Exception {
            return parser.Statements();
        }
    });
    executorService.shutdown();

    statements = future.get( parser.getConfiguration().getAsInteger(Feature.timeOut) , TimeUnit.MILLISECONDS);
} catch (TimeoutException ex) {
    parser.interrupted = true;
    throw new JSQLParserException("Time out occurred.", ex);
} catch (Exception ex) {
    throw new JSQLParserException(ex);
}
return statements;

As we can see parseStatement method creates temporary thread every time when parse statement. Therefore our highloaded application perfomance goes down then application is restarted.

Can sqlparser 4.5 library be configured to parse statement in the invokation thread (i.e. not create extra thread) ?

0

There are 0 best solutions below