mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-17 05:41:35 +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.
|
// run an update instantly.
|
||||||
getLog().info("Performing initial data load...");
|
getLog().info("Performing initial data load...");
|
||||||
|
try {
|
||||||
new UpdateTask(this, true).run();
|
new UpdateTask(this, true).run();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// register tasks
|
// register tasks
|
||||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||||
|
@ -210,7 +210,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
// run an update instantly.
|
// run an update instantly.
|
||||||
getLog().info("Performing initial data load...");
|
getLog().info("Performing initial data load...");
|
||||||
|
try {
|
||||||
new UpdateTask(this, true).run();
|
new UpdateTask(this, true).run();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// register tasks
|
// register tasks
|
||||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||||
|
@ -39,7 +39,7 @@ abstract class FlatfileConnectionFactory extends AbstractConnectionFactory {
|
|||||||
|
|
||||||
protected final File file;
|
protected final File file;
|
||||||
private final ReentrantLock lock = new ReentrantLock();
|
private final ReentrantLock lock = new ReentrantLock();
|
||||||
private Connection connection;
|
private NonClosableConnection connection;
|
||||||
|
|
||||||
FlatfileConnectionFactory(String name, File file) {
|
FlatfileConnectionFactory(String name, File file) {
|
||||||
super(name);
|
super(name);
|
||||||
@ -56,8 +56,8 @@ abstract class FlatfileConnectionFactory extends AbstractConnectionFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() throws Exception {
|
public void shutdown() throws Exception {
|
||||||
if (connection != null && !connection.isClosed()) {
|
if (connection != null) {
|
||||||
connection.close();
|
connection.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,10 @@ public final class NonClosableConnection implements Connection {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown() throws SQLException {
|
||||||
|
delegate.close();
|
||||||
|
}
|
||||||
|
|
||||||
private interface Exclude {
|
private interface Exclude {
|
||||||
void close() throws SQLException;
|
void close() throws SQLException;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,11 @@ public class LPSpongePlugin implements LuckPermsPlugin {
|
|||||||
|
|
||||||
// run an update instantly.
|
// run an update instantly.
|
||||||
getLog().info("Performing initial data load...");
|
getLog().info("Performing initial data load...");
|
||||||
|
try {
|
||||||
new UpdateTask(this, true).run();
|
new UpdateTask(this, true).run();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// register tasks
|
// register tasks
|
||||||
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);
|
||||||
|
Loading…
Reference in New Issue
Block a user