From 3f5ce27f192b17ef6646149562502e1023c9d4ea Mon Sep 17 00:00:00 2001 From: anhefti Date: Thu, 4 Mar 2021 08:22:43 +0100 Subject: [PATCH] better dispose --- .../session/impl/AsyncBatchEventSaveStrategy.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/AsyncBatchEventSaveStrategy.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/AsyncBatchEventSaveStrategy.java index eceb62d6..1dda2292 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/AsyncBatchEventSaveStrategy.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/session/impl/AsyncBatchEventSaveStrategy.java @@ -135,6 +135,7 @@ public class AsyncBatchEventSaveStrategy implements EventHandlingStrategy { SEBServerInit.INIT_LOGGER.info("> Worker Thread {} running", Thread.currentThread()); final Collection events = new ArrayList<>(); + @SuppressWarnings("resource") final SqlSessionTemplate sqlSessionTemplate = new SqlSessionTemplate( this.sqlSessionFactory, ExecutorType.BATCH); @@ -172,7 +173,11 @@ public class AsyncBatchEventSaveStrategy implements EventHandlingStrategy { } } } finally { - sqlSessionTemplate.close(); + try { + sqlSessionTemplate.destroy(); + } catch (final Exception e) { + log.error("Failed to dispose SqlSessionTemplate", e); + } log.debug("Worker Thread {} stopped", Thread.currentThread()); } };