diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/HikariSQLSourceConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/HikariSQLSourceConfig.java index 974ce17e..54e2f69f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/HikariSQLSourceConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/HikariSQLSourceConfig.java @@ -9,18 +9,25 @@ import java.util.function.Consumer; public class HikariSQLSourceConfig implements SQLSourceConfig { - private transient HikariDataSource dataSource; + private transient volatile HikariDataSource dataSource; private String dsClass; private Properties dsProps; private String driverClass; private String jdbcUrl; private String username; private String password; + private boolean initializeAtStart; public void init() { if (dataSource != null) { return; } + if(initializeAtStart) { + initializeConnection(); + } + } + + private void initializeConnection() { HikariConfig config = new HikariConfig(); consumeIfNotNull(config::setDataSourceClassName, dsClass); consumeIfNotNull(config::setDataSourceProperties, dsProps); @@ -34,6 +41,11 @@ public void init() { @Override public Connection getConnection() throws SQLException { + if(dataSource == null && !initializeAtStart) { + synchronized (this) { + initializeConnection(); + } + } return dataSource.getConnection(); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java index af1045ca..85dbd336 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/MySQLCoreProvider.java @@ -44,6 +44,7 @@ public SQLSourceConfig getSQLConfig() { @Override public void init(LaunchServer server, AuthProviderPair pair) { super.init(server, pair); + logger.warn("Method 'mysql' deprecated and may be removed in future release. Please use new 'sql' method: https://gravitlauncher.com/auth"); String userInfoCols = makeUserCols(); String hardwareInfoCols = "id, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, graphicCard, banned, publicKey"; if (sqlFindHardwareByPublicKey == null) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java index 98e36940..9b6122f8 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/PostgresSQLCoreProvider.java @@ -1,5 +1,7 @@ package pro.gravit.launchserver.auth.core; +import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.auth.AuthProviderPair; import pro.gravit.launchserver.auth.PostgreSQLSourceConfig; import pro.gravit.launchserver.auth.SQLSourceConfig; @@ -10,4 +12,10 @@ public class PostgresSQLCoreProvider extends AbstractSQLCoreProvider { public SQLSourceConfig getSQLConfig() { return postgresSQLHolder; } + + @Override + public void init(LaunchServer server, AuthProviderPair pair) { + super.init(server, pair); + logger.warn("Method 'postgresql' deprecated and may be removed in future release. Please use new 'sql' method: https://gravitlauncher.com/auth"); + } }