mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Correctly close flatfile database connections on disable, catch all exceptions when performing initial data load
This commit is contained in:
parent
cc3ddd51fd
commit
0b72507e2d
@ -271,7 +271,12 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
|
||||
// run an update instantly.
|
||||
getLog().info("Performing initial data load...");
|
||||
new UpdateTask(this, true).run();
|
||||
try {
|
||||
new UpdateTask(this, true).run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// register tasks
|
||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||
|
@ -210,7 +210,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
||||
|
||||
// run an update instantly.
|
||||
getLog().info("Performing initial data load...");
|
||||
new UpdateTask(this, true).run();
|
||||
try {
|
||||
new UpdateTask(this, true).run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
// register tasks
|
||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||
|
@ -39,7 +39,7 @@ abstract class FlatfileConnectionFactory extends AbstractConnectionFactory {
|
||||
|
||||
protected final File file;
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
private Connection connection;
|
||||
private NonClosableConnection connection;
|
||||
|
||||
FlatfileConnectionFactory(String name, File file) {
|
||||
super(name);
|
||||
@ -56,8 +56,8 @@ abstract class FlatfileConnectionFactory extends AbstractConnectionFactory {
|
||||
|
||||
@Override
|
||||
public void shutdown() throws Exception {
|
||||
if (connection != null && !connection.isClosed()) {
|
||||
connection.close();
|
||||
if (connection != null) {
|
||||
connection.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,10 @@ public final class NonClosableConnection implements Connection {
|
||||
|
||||
}
|
||||
|
||||
public void shutdown() throws SQLException {
|
||||
delegate.close();
|
||||
}
|
||||
|
||||
private interface Exclude {
|
||||
void close() throws SQLException;
|
||||
}
|
||||
|
@ -279,7 +279,11 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
||||
|
||||
// run an update instantly.
|
||||
getLog().info("Performing initial data load...");
|
||||
new UpdateTask(this, true).run();
|
||||
try {
|
||||
new UpdateTask(this, true).run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// register tasks
|
||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||
|
Loading…
Reference in New Issue
Block a user