From c2a6a408c4e8388bc96b2aa807584b7e9d16194e Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sat, 1 Jun 2024 23:10:50 +0700 Subject: [PATCH] [FIX] Hikari getConnection() deadlock when with using user_permissions table --- .../auth/core/AbstractSQLCoreProvider.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java index 857f9b7f..4e732542 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AbstractSQLCoreProvider.java @@ -276,7 +276,7 @@ public void close() { protected SQLUser constructUser(ResultSet set) throws SQLException { return set.next() ? new SQLUser(UUID.fromString(set.getString(uuidColumn)), set.getString(usernameColumn), - set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), requestPermissions(set.getString(uuidColumn))) : null; + set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn)) : null; } public ClientPermissions requestPermissions (String uuid) throws SQLException @@ -286,14 +286,17 @@ public ClientPermissions requestPermissions (String uuid) throws SQLException } private SQLUser queryUser(String sql, String value) throws SQLException { + SQLUser user; try (Connection c = getSQLConfig().getConnection()) { PreparedStatement s = c.prepareStatement(sql); s.setString(1, value); s.setQueryTimeout(MySQLSourceConfig.TIMEOUT); try (ResultSet set = s.executeQuery()) { - return constructUser(set); + user = constructUser(set); } } + user.permissions = requestPermissions(user.uuid.toString()); + return user; } private List queryPermissions(String sql, String value) throws SQLException { @@ -340,15 +343,14 @@ public static class SQLUser implements User { protected String accessToken; protected String serverId; protected final String password; - protected final ClientPermissions permissions; + protected ClientPermissions permissions; - public SQLUser(UUID uuid, String username, String accessToken, String serverId, String password, ClientPermissions permissions) { + public SQLUser(UUID uuid, String username, String accessToken, String serverId, String password) { this.uuid = uuid; this.username = username; this.accessToken = accessToken; this.serverId = serverId; this.password = password; - this.permissions = permissions; } @Override