forked from LogBlock/LogBlock
Do not spam exceptions when the database connection pool is closed
When some database access is still running asynchronously, it will create an SQLException when the pool is closed (on shutdown). Just silently ignore them in this case.
This commit is contained in:
@@ -426,10 +426,12 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
rs.close();
|
rs.close();
|
||||||
}
|
}
|
||||||
} catch (final SQLException ex) {
|
} catch (final SQLException ex) {
|
||||||
|
if (logblock.isCompletelyEnabled()) {
|
||||||
logblock.getLogger().log(Level.SEVERE, "[CommandsHandler] SQL exception on close", ex);
|
logblock.getLogger().log(Level.SEVERE, "[CommandsHandler] SQL exception on close", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class CommandLookup extends AbstractCommand {
|
public class CommandLookup extends AbstractCommand {
|
||||||
public CommandLookup(CommandSender sender, QueryParams params, boolean async) throws Exception {
|
public CommandLookup(CommandSender sender, QueryParams params, boolean async) throws Exception {
|
||||||
@@ -490,8 +492,10 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
getSession(sender).lookupCache = null;
|
getSession(sender).lookupCache = null;
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
|
if (logblock.isCompletelyEnabled() || !(ex instanceof SQLException)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||||
logblock.getLogger().log(Level.SEVERE, "[Lookup] " + params.getQuery() + ": ", ex);
|
logblock.getLogger().log(Level.SEVERE, "[Lookup] " + params.getQuery() + ": ", ex);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -546,8 +550,10 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
writer.close();
|
writer.close();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Wrote " + counter + " lines.");
|
sender.sendMessage(ChatColor.GREEN + "Wrote " + counter + " lines.");
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
|
if (logblock.isCompletelyEnabled() || !(ex instanceof SQLException)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||||
logblock.getLogger().log(Level.SEVERE, "[WriteLogFile] " + params.getQuery() + " (file was " + file.getAbsolutePath() + "): ", ex);
|
logblock.getLogger().log(Level.SEVERE, "[WriteLogFile] " + params.getQuery() + " (file was " + file.getAbsolutePath() + "): ", ex);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -606,8 +612,10 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.RED + "No block change found to teleport to");
|
sender.sendMessage(ChatColor.RED + "No block change found to teleport to");
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
|
if (logblock.isCompletelyEnabled() || !(ex instanceof SQLException)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||||
logblock.getLogger().log(Level.SEVERE, "[Teleport] " + params.getQuery() + ": ", ex);
|
logblock.getLogger().log(Level.SEVERE, "[Teleport] " + params.getQuery() + ": ", ex);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -693,8 +701,10 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
|
if (logblock.isCompletelyEnabled() || !(ex instanceof SQLException)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||||
logblock.getLogger().log(Level.SEVERE, "[Rollback] " + params.getQuery() + ": ", ex);
|
logblock.getLogger().log(Level.SEVERE, "[Rollback] " + params.getQuery() + ": ", ex);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -766,8 +776,10 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
editor.start();
|
editor.start();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Redo finished successfully (" + editor.getElapsedTime() + " ms, " + editor.getSuccesses() + "/" + changes + " blocks" + (editor.getErrors() > 0 ? ", " + ChatColor.RED + editor.getErrors() + " errors" + ChatColor.GREEN : "") + (editor.getBlacklistCollisions() > 0 ? ", " + editor.getBlacklistCollisions() + " blacklist collisions" : "") + ")");
|
sender.sendMessage(ChatColor.GREEN + "Redo finished successfully (" + editor.getElapsedTime() + " ms, " + editor.getSuccesses() + "/" + changes + " blocks" + (editor.getErrors() > 0 ? ", " + ChatColor.RED + editor.getErrors() + " errors" + ChatColor.GREEN : "") + (editor.getBlacklistCollisions() > 0 ? ", " + editor.getBlacklistCollisions() + " blacklist collisions" : "") + ")");
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
|
if (logblock.isCompletelyEnabled() || !(ex instanceof SQLException)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||||
logblock.getLogger().log(Level.SEVERE, "[Redo] " + params.getQuery() + ": ", ex);
|
logblock.getLogger().log(Level.SEVERE, "[Redo] " + params.getQuery() + ": ", ex);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@@ -841,8 +853,10 @@ public class CommandsHandler implements CommandExecutor {
|
|||||||
sender.sendMessage(ChatColor.GREEN + "Cleared out table " + table + "-chestdata. Deleted " + deleted + " entries.");
|
sender.sendMessage(ChatColor.GREEN + "Cleared out table " + table + "-chestdata. Deleted " + deleted + " entries.");
|
||||||
}
|
}
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
|
if (logblock.isCompletelyEnabled() || !(ex instanceof SQLException)) {
|
||||||
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
sender.sendMessage(ChatColor.RED + "Exception, check error log");
|
||||||
logblock.getLogger().log(Level.SEVERE, "[ClearLog] Exception: ", ex);
|
logblock.getLogger().log(Level.SEVERE, "[ClearLog] Exception: ", ex);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@@ -40,11 +40,16 @@ public class LogBlock extends JavaPlugin {
|
|||||||
private boolean errorAtLoading = false, noDb = false, connected = true;
|
private boolean errorAtLoading = false, noDb = false, connected = true;
|
||||||
private PlayerInfoLogging playerInfoLogging;
|
private PlayerInfoLogging playerInfoLogging;
|
||||||
private Questioner questioner;
|
private Questioner questioner;
|
||||||
|
private volatile boolean isCompletelyEnabled;
|
||||||
|
|
||||||
public static LogBlock getInstance() {
|
public static LogBlock getInstance() {
|
||||||
return logblock;
|
return logblock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCompletelyEnabled() {
|
||||||
|
return isCompletelyEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public Consumer getConsumer() {
|
public Consumer getConsumer() {
|
||||||
return consumer;
|
return consumer;
|
||||||
}
|
}
|
||||||
@@ -120,7 +125,6 @@ public class LogBlock extends JavaPlugin {
|
|||||||
new DumpedLogImporter(this).run();
|
new DumpedLogImporter(this).run();
|
||||||
registerEvents();
|
registerEvents();
|
||||||
consumer.start();
|
consumer.start();
|
||||||
getServer().getScheduler().runTaskAsynchronously(this, new Updater.PlayerCountChecker(this));
|
|
||||||
for (final Tool tool : toolsByType.values()) {
|
for (final Tool tool : toolsByType.values()) {
|
||||||
if (pm.getPermission("logblock.tools." + tool.name) == null) {
|
if (pm.getPermission("logblock.tools." + tool.name) == null) {
|
||||||
final Permission perm = new Permission("logblock.tools." + tool.name, tool.permissionDefault);
|
final Permission perm = new Permission("logblock.tools." + tool.name, tool.permissionDefault);
|
||||||
@@ -128,6 +132,8 @@ public class LogBlock extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
questioner = new Questioner(this);
|
questioner = new Questioner(this);
|
||||||
|
isCompletelyEnabled = true;
|
||||||
|
getServer().getScheduler().runTaskAsynchronously(this, new Updater.PlayerCountChecker(this));
|
||||||
try {
|
try {
|
||||||
Metrics metrics = new Metrics(this);
|
Metrics metrics = new Metrics(this);
|
||||||
metrics.start();
|
metrics.start();
|
||||||
@@ -204,6 +210,7 @@ public class LogBlock extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
|
isCompletelyEnabled = false;
|
||||||
if (timer != null) {
|
if (timer != null) {
|
||||||
timer.cancel();
|
timer.cancel();
|
||||||
}
|
}
|
||||||
|
@@ -825,10 +825,12 @@ class Updater {
|
|||||||
st.close();
|
st.close();
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (final SQLException ex) {
|
} catch (final SQLException ex) {
|
||||||
|
if (logblock.isCompletelyEnabled()) {
|
||||||
logblock.getLogger().log(Level.SEVERE, "[Updater] Error: ", ex);
|
logblock.getLogger().log(Level.SEVERE, "[Updater] Error: ", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MaterialUpdater1_13 {
|
public static class MaterialUpdater1_13 {
|
||||||
BlockData[][] blockDataMapping;
|
BlockData[][] blockDataMapping;
|
||||||
|
Reference in New Issue
Block a user