Skip to content

Commit

Permalink
Don't close driver class loader during disable
Browse files Browse the repository at this point in the history
Affects issues:
- Fixed #2274
  • Loading branch information
AuroraLS3 committed Feb 12, 2022
1 parent 362d1d4 commit 856d5f5
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
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.*;
Expand Down Expand Up @@ -230,6 +229,7 @@ Patch[] patches() {
*/
private void setupDatabase() {
executeTransaction(new CreateTablesTransaction());
logger.info("Database: Making sure schema is up to date..");
for (Patch patch : patches()) {
executeTransaction(patch);
}
Expand All @@ -240,6 +240,7 @@ protected void performOperations() {
}
});
registerIndexCreationTask();
logger.info("Database: Ready for operation.");
}

private void registerIndexCreationTask() {
Expand Down Expand Up @@ -279,14 +280,17 @@ public void close() {
}

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;
Expand Down

0 comments on commit 856d5f5

Please sign in to comment.