Correctly close flatfile database connections on disable, catch all exceptions when performing initial data load

This commit is contained in:
Luck 2017-12-22 22:35:13 +00:00
parent cc3ddd51fd
commit 0b72507e2d
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
5 changed files with 24 additions and 6 deletions

View File

@ -271,7 +271,12 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
// run an update instantly.
getLog().info("Performing initial data load...");
try {
new UpdateTask(this, true).run();
} catch (Exception e) {
e.printStackTrace();
}
// register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);

View File

@ -210,7 +210,12 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
// run an update instantly.
getLog().info("Performing initial data load...");
try {
new UpdateTask(this, true).run();
} catch (Exception e) {
e.printStackTrace();
}
// register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);

View File

@ -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();
}
}

View File

@ -42,6 +42,10 @@ public final class NonClosableConnection implements Connection {
}
public void shutdown() throws SQLException {
delegate.close();
}
private interface Exclude {
void close() throws SQLException;
}

View File

@ -279,7 +279,11 @@ public class LPSpongePlugin implements LuckPermsPlugin {
// run an update instantly.
getLog().info("Performing initial data load...");
try {
new UpdateTask(this, true).run();
} catch (Exception e) {
e.printStackTrace();
}
// register tasks
scheduler.asyncRepeating(new ExpireTemporaryTask(this), 60L);