mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FIX] Hikari getConnection() deadlock when with using user_permissions table
This commit is contained in:
parent
01cd50840a
commit
c2a6a408c4
1 changed files with 7 additions and 5 deletions
|
@ -276,7 +276,7 @@ public void close() {
|
||||||
|
|
||||||
protected SQLUser constructUser(ResultSet set) throws SQLException {
|
protected SQLUser constructUser(ResultSet set) throws SQLException {
|
||||||
return set.next() ? new SQLUser(UUID.fromString(set.getString(uuidColumn)), set.getString(usernameColumn),
|
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
|
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 {
|
private SQLUser queryUser(String sql, String value) throws SQLException {
|
||||||
|
SQLUser user;
|
||||||
try (Connection c = getSQLConfig().getConnection()) {
|
try (Connection c = getSQLConfig().getConnection()) {
|
||||||
PreparedStatement s = c.prepareStatement(sql);
|
PreparedStatement s = c.prepareStatement(sql);
|
||||||
s.setString(1, value);
|
s.setString(1, value);
|
||||||
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
|
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
|
||||||
try (ResultSet set = s.executeQuery()) {
|
try (ResultSet set = s.executeQuery()) {
|
||||||
return constructUser(set);
|
user = constructUser(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
user.permissions = requestPermissions(user.uuid.toString());
|
||||||
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> queryPermissions(String sql, String value) throws SQLException {
|
private List<String> queryPermissions(String sql, String value) throws SQLException {
|
||||||
|
@ -340,15 +343,14 @@ public static class SQLUser implements User {
|
||||||
protected String accessToken;
|
protected String accessToken;
|
||||||
protected String serverId;
|
protected String serverId;
|
||||||
protected final String password;
|
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.uuid = uuid;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
this.serverId = serverId;
|
this.serverId = serverId;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.permissions = permissions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue