mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-12-30 18:08:24 +01:00
Fixed MySQL connections not being released when performing a reload
This commit is contained in:
parent
8ed4216c64
commit
947c59882e
@ -13,6 +13,7 @@ import net.coreprotect.config.Config;
|
|||||||
import net.coreprotect.config.ConfigHandler;
|
import net.coreprotect.config.ConfigHandler;
|
||||||
import net.coreprotect.consumer.Consumer;
|
import net.coreprotect.consumer.Consumer;
|
||||||
import net.coreprotect.consumer.process.Process;
|
import net.coreprotect.consumer.process.Process;
|
||||||
|
import net.coreprotect.database.Database;
|
||||||
import net.coreprotect.language.Language;
|
import net.coreprotect.language.Language;
|
||||||
import net.coreprotect.language.Phrase;
|
import net.coreprotect.language.Phrase;
|
||||||
import net.coreprotect.listener.ListenerHandler;
|
import net.coreprotect.listener.ListenerHandler;
|
||||||
@ -189,6 +190,7 @@ public final class CoreProtect extends JavaPlugin {
|
|||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Database.closeConnection();
|
||||||
Chat.console(Phrase.build(Phrase.DISABLE_SUCCESS, "CoreProtect v" + plugin.getDescription().getVersion()));
|
Chat.console(Phrase.build(Phrase.DISABLE_SUCCESS, "CoreProtect v" + plugin.getDescription().getVersion()));
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -175,10 +175,7 @@ public class ConfigHandler extends Queue {
|
|||||||
|
|
||||||
public static void loadDatabase() {
|
public static void loadDatabase() {
|
||||||
// close old pool when we reload the database, e.g. in purge command
|
// close old pool when we reload the database, e.g. in purge command
|
||||||
if (ConfigHandler.hikariDataSource != null) {
|
Database.closeConnection();
|
||||||
ConfigHandler.hikariDataSource.close();
|
|
||||||
ConfigHandler.hikariDataSource = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Config.getGlobal().MYSQL) {
|
if (!Config.getGlobal().MYSQL) {
|
||||||
try {
|
try {
|
||||||
|
@ -175,6 +175,18 @@ public class Database extends Queue {
|
|||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void closeConnection() {
|
||||||
|
try {
|
||||||
|
if (ConfigHandler.hikariDataSource != null) {
|
||||||
|
ConfigHandler.hikariDataSource.close();
|
||||||
|
ConfigHandler.hikariDataSource = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void performUpdate(Statement statement, long id, int action, int table) {
|
public static void performUpdate(Statement statement, long id, int action, int table) {
|
||||||
try {
|
try {
|
||||||
int rolledBack = 1;
|
int rolledBack = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user