Commit 58f0a808 authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Add cleanup hook

parent 3da98b3e
...@@ -36,7 +36,6 @@ public class DatabaseHandler { ...@@ -36,7 +36,6 @@ public class DatabaseHandler {
public DatabaseHandler(){ public DatabaseHandler(){
try { try {
// Cleanup hook Runtime.getRuntime().addShutdownHook(new Thread(() -> {}));
String jdbcurl = H2GISDBFactory.createDataSource(DB_NAME, String jdbcurl = H2GISDBFactory.createDataSource(DB_NAME,
true, ";AUTO_SERVER=TRUE").getConnection().getMetaData().getURL(); true, ";AUTO_SERVER=TRUE").getConnection().getMetaData().getURL();
HikariDataSource ds = new HikariDataSource(); HikariDataSource ds = new HikariDataSource();
...@@ -50,6 +49,8 @@ public class DatabaseHandler { ...@@ -50,6 +49,8 @@ public class DatabaseHandler {
dataSource = new DataSourceWrapper(ds); dataSource = new DataSourceWrapper(ds);
//Cleanup hook
Runtime.getRuntime().addShutdownHook(new Thread(ds::close));
} catch (Exception e) { } catch (Exception e) {
logger.fatal("FATAL ERROR: Creation of embedded database failed!"); logger.fatal("FATAL ERROR: Creation of embedded database failed!");
logger.fatal(e.getMessage()); logger.fatal(e.getMessage());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment