From 74db09e69e00090d4a40678ccf87d45037d5d6dd Mon Sep 17 00:00:00 2001 From: Eric Date: Sat, 29 Feb 2020 17:34:47 +0100 Subject: [PATCH] Remove async option from SQLite#vacuum() --- .../java/de/epiceric/shopchest/ShopChest.java | 2 +- .../de/epiceric/shopchest/sql/SQLite.java | 33 ++++++------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java index 9aa1801..c5065d7 100644 --- a/src/main/java/de/epiceric/shopchest/ShopChest.java +++ b/src/main/java/de/epiceric/shopchest/ShopChest.java @@ -251,7 +251,7 @@ public class ShopChest extends JavaPlugin { if (database != null) { if (database instanceof SQLite) { - ((SQLite) database).vacuum(false); + ((SQLite) database).vacuum(); } database.disconnect(); diff --git a/src/main/java/de/epiceric/shopchest/sql/SQLite.java b/src/main/java/de/epiceric/shopchest/sql/SQLite.java index 07dd334..02b3cb4 100644 --- a/src/main/java/de/epiceric/shopchest/sql/SQLite.java +++ b/src/main/java/de/epiceric/shopchest/sql/SQLite.java @@ -52,31 +52,18 @@ public class SQLite extends Database { } /** - * Vacuums the database to reduce file size - * - * @param async Whether the call should be executed asynchronously + * Vacuums the database synchronously to reduce file size */ - public void vacuum(boolean async) { - BukkitRunnable runnable = new BukkitRunnable() { - @Override - public void run() { - try (Connection con = dataSource.getConnection(); - Statement s = con.createStatement()) { - s.executeUpdate("VACUUM"); + public void vacuum() { + try (Connection con = dataSource.getConnection(); + Statement s = con.createStatement()) { + s.executeUpdate("VACUUM"); - plugin.debug("Vacuumed SQLite database"); - } catch (final SQLException ex) { - plugin.getLogger().severe("Failed to vacuum database"); - plugin.debug("Failed to vacuum database"); - plugin.debug(ex); - } - } - }; - - if (async) { - runnable.runTaskAsynchronously(plugin); - } else { - runnable.run(); + plugin.debug("Vacuumed SQLite database"); + } catch (final SQLException ex) { + plugin.getLogger().warning("Failed to vacuum database"); + plugin.debug("Failed to vacuum database"); + plugin.debug(ex); } }