From 856d5f57e71e49793e875207016f673fe0dbb41d Mon Sep 17 00:00:00 2001 From: Risto Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Sat, 12 Feb 2022 22:59:04 +0200 Subject: [PATCH] Don't close driver class loader during disable Affects issues: - Fixed #2274 --- .../plan/storage/database/SQLDB.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java index b4f2e2e4b..ee6ef27fe 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/storage/database/SQLDB.java @@ -46,7 +46,6 @@ import net.playeranalytics.plugin.scheduling.TimeAmount; import net.playeranalytics.plugin.server.PluginLogger; import org.apache.commons.lang3.concurrent.BasicThreadFactory; -import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; import java.util.*; @@ -230,6 +229,7 @@ public abstract class SQLDB extends AbstractDatabase { */ private void setupDatabase() { executeTransaction(new CreateTablesTransaction()); + logger.info("Database: Making sure schema is up to date.."); for (Patch patch : patches()) { executeTransaction(patch); } @@ -240,6 +240,7 @@ public abstract class SQLDB extends AbstractDatabase { } }); registerIndexCreationTask(); + logger.info("Database: Ready for operation."); } private void registerIndexCreationTask() { @@ -279,14 +280,17 @@ public abstract class SQLDB extends AbstractDatabase { } private void unloadDriverClassloader() { - try { - if (driverClassLoader instanceof IsolatedClassLoader) { - ((IsolatedClassLoader) driverClassLoader).close(); - } + // Unloading class loader causes issues when reloading. + // It is better to leak this memory than crash the plugin on reload. + +// try { +// if (driverClassLoader instanceof IsolatedClassLoader) { +// ((IsolatedClassLoader) driverClassLoader).close(); +// } driverClassLoader = null; - } catch (IOException e) { - errorLogger.error(e, ErrorContext.builder().build()); - } +// } catch (IOException e) { +// errorLogger.error(e, ErrorContext.builder().build()); +// } } public abstract Connection getConnection() throws SQLException;