mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-01 05:57:51 +01:00
Better null checking in HikariConnectionFactory (#1408)
This commit is contained in:
parent
22252fa46d
commit
83db00aef8
@ -49,6 +49,8 @@ public class InfoCommand extends SingleCommand {
|
||||
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
|
||||
Map<String, String> storageMeta = plugin.getStorage().getMeta();
|
||||
|
||||
Message.INFO_TOP.send(sender,
|
||||
plugin.getBootstrap().getVersion(),
|
||||
plugin.getBootstrap().getType().getFriendlyName(),
|
||||
@ -57,7 +59,7 @@ public class InfoCommand extends SingleCommand {
|
||||
);
|
||||
|
||||
Message.INFO_STORAGE.send(sender, plugin.getStorage().getName());
|
||||
for (Map.Entry<String, String> e : plugin.getStorage().getMeta().entrySet()) {
|
||||
for (Map.Entry<String, String> e : storageMeta.entrySet()) {
|
||||
Message.INFO_STORAGE_META.send(sender, e.getKey(), formatValue(e.getValue()));
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,7 @@ import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class HikariConnectionFactory implements ConnectionFactory {
|
||||
|
||||
@ -103,7 +104,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
||||
boolean success = true;
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
try (Connection c = this.hikari.getConnection()) {
|
||||
try (Connection c = getConnection()) {
|
||||
try (Statement s = c.createStatement()) {
|
||||
s.execute("/* ping */ SELECT 1");
|
||||
}
|
||||
@ -124,9 +125,12 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
if (this.hikari == null) {
|
||||
throw new SQLException("Unable to get a connection from the pool. (hikari is null)");
|
||||
}
|
||||
Connection connection = this.hikari.getConnection();
|
||||
if (connection == null) {
|
||||
throw new SQLException("Unable to get a connection from the pool.");
|
||||
throw new SQLException("Unable to get a connection from the pool. (getConnection returned null)");
|
||||
}
|
||||
return connection;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user