Merge pull request #515 from microwin7/dev

Update dependencies and fix HikariCP
This commit is contained in:
Gravit 2021-09-04 19:59:29 +07:00 committed by GitHub
commit acf106baa9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 14 deletions

View file

@ -92,8 +92,8 @@ pack project(':LauncherAPI')
bundle group: 'io.jsonwebtoken', name: 'jjwt-gson', version: rootProject['verJwt'] bundle group: 'io.jsonwebtoken', name: 'jjwt-gson', version: rootProject['verJwt']
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit'] testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter', version: rootProject['verJunit']
hikari 'io.micrometer:micrometer-core:1.5.10' hikari 'io.micrometer:micrometer-core:1.7.2'
hikari('com.zaxxer:HikariCP:4.0.3') { hikari('com.zaxxer:HikariCP:5.0.0') {
exclude group: 'javassist' exclude group: 'javassist'
exclude group: 'io.micrometer' exclude group: 'io.micrometer'
exclude group: 'org.slf4j' exclude group: 'org.slf4j'
@ -112,7 +112,7 @@ pack project(':LauncherAPI')
compileOnlyA group: 'com.google.guava', name: 'guava', version: rootProject['verGuavaC'] compileOnlyA group: 'com.google.guava', name: 'guava', version: rootProject['verGuavaC']
// Do not update (laggy deps). // Do not update (laggy deps).
compileOnlyA 'log4j:log4j:1.2.17' compileOnlyA 'log4j:log4j:1.2.17'
compileOnlyA 'org.apache.logging.log4j:log4j-core:2.11.2' compileOnlyA 'org.apache.logging.log4j:log4j-core:2.14.1'
} }
task hikari(type: Copy) { task hikari(type: Copy) {

View file

@ -32,8 +32,8 @@ public final class MySQLSourceConfig implements AutoCloseable {
private String username; private String username;
private String password; private String password;
private String database; private String database;
private String timeZone; private String timezone;
private boolean enableHikari; private boolean useHikari;
// Cache // Cache
private transient DataSource source; private transient DataSource source;
@ -93,22 +93,26 @@ public synchronized Connection getConnection() throws SQLException {
mysqlSource.setPassword(password); mysqlSource.setPassword(password);
mysqlSource.setDatabaseName(database); mysqlSource.setDatabaseName(database);
mysqlSource.setTcpNoDelay(true); mysqlSource.setTcpNoDelay(true);
if (timeZone != null) mysqlSource.setServerTimezone(timeZone); if (timezone != null) mysqlSource.setServerTimezone(timezone);
hikari = false; hikari = false;
// Try using HikariCP // Try using HikariCP
source = mysqlSource; source = mysqlSource;
if (enableHikari) { if (useHikari) {
try { try {
Class.forName("com.zaxxer.hikari.HikariDataSource"); Class.forName("com.zaxxer.hikari.HikariDataSource");
hikari = true; // Used for shutdown. Not instanceof because of possible classpath error hikari = true; // Used for shutdown. Not instanceof because of possible classpath error
HikariConfig cfg = new HikariConfig(); HikariConfig hikariConfig = new HikariConfig();
cfg.setDataSource(mysqlSource); hikariConfig.setDataSource(mysqlSource);
cfg.setPoolName(poolName); hikariConfig.setPoolName(poolName);
cfg.setMaximumPoolSize(MAX_POOL_SIZE); hikariConfig.setMinimumIdle(1);
hikariConfig.setMaximumPoolSize(MAX_POOL_SIZE);
hikariConfig.setConnectionTestQuery("SELECT 1");
hikariConfig.setConnectionTimeout(1000);
hikariConfig.setAutoCommit(true);
hikariConfig.setLeakDetectionThreshold(2000);
// Set HikariCP pool // Set HikariCP pool
// Replace source with hds // Replace source with hds
source = new HikariDataSource(cfg); source = new HikariDataSource(hikariConfig);
logger.warn("HikariCP pooling enabled for '{}'", poolName);
} catch (ClassNotFoundException ignored) { } catch (ClassNotFoundException ignored) {
logger.debug("HikariCP isn't in classpath for '{}'", poolName); logger.debug("HikariCP isn't in classpath for '{}'", poolName);
} }

View file

@ -24,9 +24,10 @@ public final class MySQLAuthProvider extends AuthProvider {
@Override @Override
public void init(LaunchServer srv) { public void init(LaunchServer srv) {
super.init(srv); super.init(srv);
if (mySQLHolder == null) throw new RuntimeException("[Verify][AuthProvider] mySQLHolder cannot be null");
if (query == null) throw new RuntimeException("[Verify][AuthProvider] query cannot be null"); if (query == null) throw new RuntimeException("[Verify][AuthProvider] query cannot be null");
if (message == null) throw new RuntimeException("[Verify][AuthProvider] message cannot be null"); if (message == null) throw new RuntimeException("[Verify][AuthProvider] message cannot be null");
if (mySQLHolder == null) throw new RuntimeException("[Verify][AuthProvider] mySQLHolder cannot be null"); if (queryParams == null) throw new RuntimeException("[Verify][AuthProvider] queryParams cannot be null");
} }
@Override @Override