diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e336cbe56..000000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -dist: trusty -language: java -install: true -sudo: required - -services: - - docker - -jdk: - - oraclejdk8 - -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ - -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ - -stages: -- name: build -- name: release - if: branch IN (release) AND type = push - -jobs: - include: - - stage: build - script: - # - ./gradlew build -Pnetty_version=4.0.56.Final - # - ./gradlew clean build -x test - # - ./gradlew :mysq-async:test --tests com.github.jasync.sql.db.mysql.QueryTimeoutSpec --info - - ./resources/run-docker-memsql.sh - - ./gradlew clean build - - ./resources/detect-leak.sh mysql-async/target/mysql-async-tests.log - - ./resources/detect-leak.sh postgresql-async/target/postgresql-async-tests.log - - ./gradlew codeCoverageReport - after_success: - - bash <(curl -s https://codecov.io/bash) -t $CODECOV_TOKEN - - stage: release - script: ./gradlew clean build publishToSonatype closeAndReleaseSonatypeStagingRepository -no-daemon --no-parallel -x test diff --git a/build.gradle.kts b/build.gradle.kts index 198411098..7af50e734 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,7 +24,7 @@ apply(plugin = "io.github.gradle-nexus.publish-plugin") allprojects { group = "com.github.jasync-sql" - version = "2.1.26" + version = "2.2.0" apply(plugin = "kotlin") apply(plugin = "maven-publish") @@ -91,10 +91,6 @@ subprojects { withJavadocJar() } - sourceSets.main { - java.srcDirs("src/main/java") - } - val varintName = when (project.name) { "db-async-common" -> "jasync-common" "pool-async" -> "jasync-pool" diff --git a/db-async-common/build.gradle.kts b/db-async-common/build.gradle.kts index a80ece15a..b1887e834 100644 --- a/db-async-common/build.gradle.kts +++ b/db-async-common/build.gradle.kts @@ -11,15 +11,15 @@ val LOGBACK_VERSION: String by project val AWAITILITY_VERSION: String by project dependencies { - compile(project(":pool-async")) + api(project(":pool-async")) api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") - compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") implementation("org.slf4j:slf4j-api:$SL4J_VERSION") implementation("io.netty:netty-transport:$NETTY_VERSION") implementation("io.netty:netty-handler:$NETTY_VERSION") compileOnly("io.netty:netty-transport-native-epoll:$NETTY_VERSION:linux-x86_64") compileOnly("io.netty:netty-transport-native-kqueue:$NETTY_VERSION:osx-x86_64") - implementation("io.github.microutils:kotlin-logging:$KOTLIN_LOGGING_VERSION") + implementation("io.github.oshai:kotlin-logging-jvm:$KOTLIN_LOGGING_VERSION") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$KOTLIN_COROUTINES_VERSION") testImplementation("junit:junit:$JUNIT_VERSION") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION") diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/ConcreteConnectionBase.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/ConcreteConnectionBase.kt index 6467eb4a0..c522a71a3 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/ConcreteConnectionBase.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/ConcreteConnectionBase.kt @@ -24,10 +24,11 @@ abstract class ConcreteConnectionBase( val p = CompletableFuture() f(this).onCompleteAsync(configuration.executionContext) { ty1 -> sendQuery(if (ty1.isFailure) "ROLLBACK" else "COMMIT").onCompleteAsync(configuration.executionContext) { ty2 -> - if (ty2.isFailure && ty1.isSuccess) + if (ty2.isFailure && ty1.isSuccess) { p.failed((ty2 as Failure).exception) - else + } else { p.complete(ty1) + } } } p diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/Configuration.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/Configuration.kt index e23661a67..0ebc9e174 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/Configuration.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/Configuration.kt @@ -3,12 +3,12 @@ package com.github.jasync.sql.db import com.github.jasync.sql.db.interceptor.QueryInterceptor import com.github.jasync.sql.db.util.ExecutorServiceUtils import com.github.jasync.sql.db.util.NettyUtils +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBufAllocator import io.netty.buffer.PooledByteBufAllocator import io.netty.channel.EventLoopGroup import io.netty.channel.nio.NioEventLoopGroup import io.netty.util.CharsetUtil -import mu.KotlinLogging import java.nio.charset.Charset import java.nio.file.Path import java.time.Duration @@ -66,7 +66,7 @@ class Configuration @JvmOverloads constructor( val currentSchema: String? = null, val socketPath: String? = null, val credentialsProvider: CredentialsProvider? = null, - val rsaPublicKey: Path? = null, + val rsaPublicKey: Path? = null ) { init { if (socketPath != null && eventLoopGroup is NioEventLoopGroup) { @@ -99,7 +99,7 @@ class Configuration @JvmOverloads constructor( currentSchema: String? = null, socketPath: String? = null, credentialsProvider: CredentialsProvider? = null, - rsaPublicKey: Path? = null, + rsaPublicKey: Path? = null ): Configuration { return Configuration( username = username ?: this.username, @@ -120,14 +120,14 @@ class Configuration @JvmOverloads constructor( currentSchema = currentSchema ?: this.currentSchema, socketPath = socketPath ?: this.socketPath, credentialsProvider = credentialsProvider ?: this.credentialsProvider, - rsaPublicKey = rsaPublicKey ?: this.rsaPublicKey, + rsaPublicKey = rsaPublicKey ?: this.rsaPublicKey ) } @Deprecated( "backward compatibility for https://github.com/jasync-sql/jasync-sql/issues/359", ReplaceWith("copy()"), - DeprecationLevel.ERROR, + DeprecationLevel.ERROR ) fun copy( username: String? = null, @@ -146,7 +146,7 @@ class Configuration @JvmOverloads constructor( eventLoopGroup: EventLoopGroup? = null, executionContext: Executor? = null, currentSchema: String? = null, - socketPath: String? = null, + socketPath: String? = null ): Configuration { return Configuration( username = username ?: this.username, @@ -167,7 +167,7 @@ class Configuration @JvmOverloads constructor( currentSchema = currentSchema ?: this.currentSchema, socketPath = socketPath ?: this.socketPath, credentialsProvider = this.credentialsProvider, - rsaPublicKey = this.rsaPublicKey, + rsaPublicKey = this.rsaPublicKey ) } diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/ConnectionPoolConfiguration.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/ConnectionPoolConfiguration.kt index 5518d107f..1b8f0894a 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/ConnectionPoolConfiguration.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/ConnectionPoolConfiguration.kt @@ -79,7 +79,7 @@ class ConnectionPoolConfiguration @JvmOverloads constructor( val currentSchema: String? = null, val socketPath: String? = null, val credentialsProvider: CredentialsProvider? = null, - val minIdleConnections: Int? = null, + val minIdleConnections: Int? = null ) { init { require(port > 0) { "port should be positive: $port" } @@ -130,7 +130,7 @@ class ConnectionPoolConfiguration @JvmOverloads constructor( testTimeout = connectionTestTimeout, queryTimeout = queryTimeout, coroutineDispatcher = coroutineDispatcher, - minIdleObjects = minIdleConnections, + minIdleObjects = minIdleConnections ) override fun toString() = """ConnectionPoolConfiguration(host=$host, port=REDACTED, @@ -151,7 +151,8 @@ class ConnectionPoolConfiguration @JvmOverloads constructor( |interceptors=$interceptors, |maxConnectionTtl=$maxConnectionTtl |minIdleConnections=$minIdleConnections)""${'"'}.trimMargin() -|)""".trimMargin() +|) + """.trimMargin() @JvmOverloads fun copy( @@ -180,7 +181,7 @@ class ConnectionPoolConfiguration @JvmOverloads constructor( currentSchema: String? = null, socketPath: String? = null, credentialsProvider: CredentialsProvider? = null, - minIdleConnections: Int? = null, + minIdleConnections: Int? = null ): ConnectionPoolConfiguration { return ConnectionPoolConfiguration( username = username ?: this.username, @@ -341,6 +342,6 @@ data class ConnectionPoolConfigurationBuilder @JvmOverloads constructor( currentSchema = currentSchema, socketPath = socketPath, credentialsProvider = credentialsProvider, - minIdleConnections = minIdleConnections, + minIdleConnections = minIdleConnections ) } diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/exceptions/InsufficientParametersException.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/exceptions/InsufficientParametersException.kt index 6465c1e34..ea290f1e9 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/exceptions/InsufficientParametersException.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/exceptions/InsufficientParametersException.kt @@ -12,6 +12,8 @@ package com.github.jasync.sql.db.exceptions @Suppress("RedundantVisibilityModifier") public class InsufficientParametersException(expected: Int, given: List) : DatabaseException( "The query contains %s parameters but you gave it %s (%s)".format( - expected, given.size, given.joinToString(",") + expected, + given.size, + given.joinToString(",") ) ) diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/interceptor/Interceptors.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/interceptor/Interceptors.kt index 7e88c7e55..28205080a 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/interceptor/Interceptors.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/interceptor/Interceptors.kt @@ -2,7 +2,7 @@ package com.github.jasync.sql.db.interceptor import com.github.jasync.sql.db.QueryResult import com.github.jasync.sql.db.util.mapTry -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.slf4j.MDC import java.util.concurrent.CompletableFuture import java.util.function.Supplier diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionFactory.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionFactory.kt index ec606b2d0..070b6c85c 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionFactory.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionFactory.kt @@ -8,7 +8,7 @@ import com.github.jasync.sql.db.interceptor.PreparedStatementParams import com.github.jasync.sql.db.util.FP import com.github.jasync.sql.db.util.Try import com.github.jasync.sql.db.util.map -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.CompletableFuture private val logger = KotlinLogging.logger {} diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionPool.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionPool.kt index 77d24b44f..0a1c209cf 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionPool.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/pool/ConnectionPool.kt @@ -9,7 +9,7 @@ import com.github.jasync.sql.db.interceptor.wrapPreparedStatementWithInterceptor import com.github.jasync.sql.db.interceptor.wrapQueryWithInterceptors import com.github.jasync.sql.db.util.FP import com.github.jasync.sql.db.util.mapAsync -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.CompletableFuture private val logger = KotlinLogging.logger {} @@ -69,7 +69,6 @@ class ConnectionPool( values: List, release: Boolean ): CompletableFuture { - return wrapPreparedStatementWithInterceptors( PreparedStatementParams(query, values, release), configuration.interceptors @@ -131,6 +130,8 @@ class ConnectionPool( fun giveBack(item: T): CompletableFuture> = objectPool.giveBack(item) + fun softEvictConnections(): CompletableFuture> = objectPool.softEvict() + /** * * Closes the pool diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/pool/TimeoutScheduler.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/pool/TimeoutScheduler.kt index 59835d8bd..d4e784ef0 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/pool/TimeoutScheduler.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/pool/TimeoutScheduler.kt @@ -3,8 +3,8 @@ package com.github.jasync.sql.db.pool import com.github.jasync.sql.db.util.nullableMap import com.github.jasync.sql.db.util.onCompleteAsync import com.github.jasync.sql.db.util.tryFailure +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.channel.EventLoopGroup -import mu.KotlinLogging import java.time.Duration import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/util/AbstractURIParser.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/util/AbstractURIParser.kt index df087a82d..e036122c5 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/util/AbstractURIParser.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/util/AbstractURIParser.kt @@ -3,7 +3,7 @@ package com.github.jasync.sql.db.util import com.github.jasync.sql.db.Configuration import com.github.jasync.sql.db.SSLConfiguration import com.github.jasync.sql.db.exceptions.UnableToParseURLException -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.net.URI import java.net.URISyntaxException import java.net.URLDecoder @@ -140,7 +140,9 @@ abstract class AbstractURIParser { protected fun unwrapIpv6address(server: String): String { return if (server.startsWith("<")) { server.substring(1, server.length - 1) - } else server + } else { + server + } } companion object { diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/util/NettyUtils.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/util/NettyUtils.kt index 15c24bb92..af8662009 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/util/NettyUtils.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/util/NettyUtils.kt @@ -2,6 +2,7 @@ package com.github.jasync.sql.db.util import com.github.jasync.sql.db.Configuration import com.github.jasync.sql.db.SSLConfiguration +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.channel.Channel import io.netty.channel.EventLoopGroup import io.netty.channel.epoll.Epoll @@ -20,7 +21,6 @@ import io.netty.handler.ssl.SslContextBuilder import io.netty.handler.ssl.util.InsecureTrustManagerFactory import io.netty.util.internal.logging.InternalLoggerFactory import io.netty.util.internal.logging.Slf4JLoggerFactory -import mu.KotlinLogging import java.io.FileInputStream import java.net.InetSocketAddress import java.net.SocketAddress diff --git a/db-async-common/src/main/java/com/github/jasync/sql/db/util/PrintUtils.kt b/db-async-common/src/main/java/com/github/jasync/sql/db/util/PrintUtils.kt index 791659061..e0b86faad 100644 --- a/db-async-common/src/main/java/com/github/jasync/sql/db/util/PrintUtils.kt +++ b/db-async-common/src/main/java/com/github/jasync/sql/db/util/PrintUtils.kt @@ -2,8 +2,8 @@ package com.github.jasync.sql.db.util +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf -import mu.KotlinLogging object PrintUtils { diff --git a/db-async-common/src/test/java/com/github/jasync/sql/db/ConnectionPoolConfigurationTest.kt b/db-async-common/src/test/java/com/github/jasync/sql/db/ConnectionPoolConfigurationTest.kt index ad37c2dc2..b67504e3c 100644 --- a/db-async-common/src/test/java/com/github/jasync/sql/db/ConnectionPoolConfigurationTest.kt +++ b/db-async-common/src/test/java/com/github/jasync/sql/db/ConnectionPoolConfigurationTest.kt @@ -30,7 +30,7 @@ class ConnectionPoolConfigurationTest { maximumMessageSize = 17, applicationName = "applicationName", maxConnectionTtl = 18, - minIdleConnections = 5, + minIdleConnections = 5 ).build() assertThat(configuration.host).isEqualTo("host") assertThat(configuration.connectionConfiguration.host).isEqualTo("host") diff --git a/db-async-common/src/test/java/com/github/jasync/sql/db/util/HexCodecSpec.kt b/db-async-common/src/test/java/com/github/jasync/sql/db/util/HexCodecSpec.kt index f8368587d..a6800318f 100644 --- a/db-async-common/src/test/java/com/github/jasync/sql/db/util/HexCodecSpec.kt +++ b/db-async-common/src/test/java/com/github/jasync/sql/db/util/HexCodecSpec.kt @@ -52,7 +52,6 @@ class HexCodecSpec { @Test fun `correctly generate a byte array from the PG output`() { - val input = "\\x53617920" val bytes = byteArrayOf(83, 97, 121, 32) assertEquals(HexCodec.decode(input, 2).toList(), bytes.toList()) diff --git a/db-async-common/src/test/java/com/github/jasync/sql/db/util/VersionSpec.kt b/db-async-common/src/test/java/com/github/jasync/sql/db/util/VersionSpec.kt index 6fd151312..68db4625c 100644 --- a/db-async-common/src/test/java/com/github/jasync/sql/db/util/VersionSpec.kt +++ b/db-async-common/src/test/java/com/github/jasync/sql/db/util/VersionSpec.kt @@ -23,7 +23,6 @@ class VersionSpec { @Test fun `correctly compare between major different versions 1`() { - val version1 = parseVersion("8.2.0") val version2 = parseVersion("9.2.0") @@ -32,7 +31,6 @@ class VersionSpec { @Test fun `correctly compare between major different versions 2`() { - val version1 = parseVersion("8.2.0") val version2 = parseVersion("8.2.0") @@ -41,7 +39,6 @@ class VersionSpec { @Test fun `correctly compare between major different versions 3`() { - val version1 = parseVersion("8.2.8") val version2 = parseVersion("8.2.87") @@ -50,7 +47,6 @@ class VersionSpec { @Test fun `correctly compare two different versions`() { - val version1 = parseVersion("9.1.2") val version2 = parseVersion("9.2.0") diff --git a/gradle.properties b/gradle.properties index a04036877..ab4927621 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,22 @@ -KOTLIN_VERSION=1.6.21 -KTLINT_VERSION=11.0.0 +KOTLIN_VERSION=1.8.21 +KTLINT_VERSION=11.3.1 JACOCO_VERSION=0.8.8 -KOTLIN_COROUTINES_VERSION=1.6.1 -SL4J_VERSION=1.7.25 -JODA_VERSION=2.11.2 -JODA_CONVERT_VERSION=2.2.2 -NETTY_VERSION=4.1.86.Final -KOTLIN_LOGGING_VERSION=2.1.21 +KOTLIN_COROUTINES_VERSION=1.7.1 +SL4J_VERSION=2.0.7 +JODA_VERSION=2.12.5 +JODA_CONVERT_VERSION=2.2.3 +NETTY_VERSION=4.1.93.Final +KOTLIN_LOGGING_VERSION=4.0.0-beta-29 SCRAM_CLIENT_VERSION=2.1 R2DBC_SPI_VERSION=1.0.0.RELEASE -REACTOR_CORE_VERSION=3.4.23 +REACTOR_CORE_VERSION=3.5.7 +REACTOR_KOTLIN_EXTENSION=1.2.2 JUNIT_VERSION=4.13.2 ASSERTJ_VERSION=3.23.1 MOCKK_VERSION=1.9 -LOGBACK_VERSION=1.1.8 +LOGBACK_VERSION=1.3.8 TEST_CONTAINERS_VERSION=1.17.6 MYSQL_CONNECTOR_VERSION=5.1.47 AWAITILITY_VERSION=3.1.5 -THREETEN_EXTRA=1.6.0 +THREETEN_EXTRA=1.7.2 JTS_VERSION=1.19.0 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f11982043..d4aebfed0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/mysql-async/build.gradle.kts b/mysql-async/build.gradle.kts index 6b18449f0..0c1924828 100644 --- a/mysql-async/build.gradle.kts +++ b/mysql-async/build.gradle.kts @@ -13,15 +13,15 @@ val MYSQL_CONNECTOR_VERSION: String by project val AWAITILITY_VERSION: String by project dependencies { - compile(project(":pool-async")) - compile(project(":db-async-common")) - compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") - compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") - compile("org.slf4j:slf4j-api:$SL4J_VERSION") - compile("io.netty:netty-transport:$NETTY_VERSION") - compile("io.netty:netty-handler:$NETTY_VERSION") + api(project(":pool-async")) + api(project(":db-async-common")) + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") + api("org.slf4j:slf4j-api:$SL4J_VERSION") + api("io.netty:netty-transport:$NETTY_VERSION") + api("io.netty:netty-handler:$NETTY_VERSION") testImplementation("io.netty:netty-transport-native-epoll:$NETTY_VERSION:linux-x86_64") - compile("io.github.microutils:kotlin-logging:$KOTLIN_LOGGING_VERSION") + api("io.github.oshai:kotlin-logging-jvm:$KOTLIN_LOGGING_VERSION") testImplementation("junit:junit:$JUNIT_VERSION") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION") testImplementation("org.assertj:assertj-core:$ASSERTJ_VERSION") diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/MySQLConnection.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/MySQLConnection.kt index 34f633ef8..cae6ca6cd 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/MySQLConnection.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/MySQLConnection.kt @@ -43,9 +43,9 @@ import com.github.jasync.sql.db.util.onFailureAsync import com.github.jasync.sql.db.util.parseVersion import com.github.jasync.sql.db.util.success import com.github.jasync.sql.db.util.toCompletableFuture +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.channel.ChannelHandlerContext import io.netty.handler.ssl.SslHandler -import mu.KotlinLogging import java.time.Duration import java.util.Optional import java.util.concurrent.CancellationException @@ -315,7 +315,7 @@ class MySQLConnection @JvmOverloads constructor( password = configuration.password, appName = configuration.applicationName, sslConfiguration = configuration.ssl, - rsaPublicKey = configuration.rsaPublicKey, + rsaPublicKey = configuration.rsaPublicKey ) if (!switchToSsl) { @@ -394,8 +394,11 @@ class MySQLConnection @JvmOverloads constructor( sendQuery(query) }.mapTry { queryResult, throwable -> // Cancellation exception will be ignored so that the following transaction clean up can be executed - if (throwable is CancellationException) QueryResult(rowsAffected = 0L, statusMessage = null) - else queryResult + if (throwable is CancellationException) { + QueryResult(rowsAffected = 0L, statusMessage = null) + } else { + queryResult + } } } @@ -503,8 +506,9 @@ class MySQLConnection @JvmOverloads constructor( private fun queryPromise(): Optional> = queryPromiseReference.get() private fun setQueryPromise(promise: CompletableFuture) { - if (!this.queryPromiseReference.compareAndSet(Optional.empty(), Optional.of(promise))) + if (!this.queryPromiseReference.compareAndSet(Optional.empty(), Optional.of(promise))) { throw ConnectionStillRunningQueryException(this.id, true) + } } private fun clearQueryPromise(): Optional> { diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoder.kt index 7fd4f6d41..63464318d 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoder.kt @@ -4,15 +4,14 @@ import com.github.jasync.sql.db.exceptions.BufferNotFullyConsumedException import com.github.jasync.sql.db.mysql.message.server.ColumnDefinitionMessage import com.github.jasync.sql.db.util.BufferDumper import com.github.jasync.sql.db.util.PrintUtils +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf -import mu.KotlinLogging private val logger = KotlinLogging.logger {} class BinaryRowDecoder { fun decode(buffer: ByteBuf, columns: List): Array { - logger.trace { "columns are ${buffer.readableBytes()} - $columns" } logger.trace { "decoding row\n${BufferDumper.dumpAsHex(buffer)}" } PrintUtils.printArray("bitmap", buffer) @@ -31,7 +30,6 @@ class BinaryRowDecoder { val result = if ((nullBitMask[nullMaskPos].toInt() and bit) != 0) { null } else { - val column = columns[it] logger.trace { "${buffer.readableBytes()}" } diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowEncoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowEncoder.kt index 7a661a138..aeb478891 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowEncoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/BinaryRowEncoder.kt @@ -71,7 +71,6 @@ class BinaryRowEncoder(charset: Charset) { ) fun encoderFor(v: Any): BinaryEncoder { - return this.encoders.getOrElse(v::class.java) { return when (v) { is CharSequence -> this.stringEncoder diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimeDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimeDecoder.kt index 1619a7edd..57996a844 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimeDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimeDecoder.kt @@ -12,12 +12,10 @@ import java.time.Duration object TimeDecoder : BinaryDecoder { override fun decode(buffer: ByteBuf): Duration { - val unsignedByte = buffer.readUnsignedByte() return when (unsignedByte) { 0.toShort() -> 0.seconds 8.toShort() -> { - val isNegative = buffer.readUnsignedByte() == 1.toShort() val duration = buffer.readUnsignedInt().days + @@ -32,7 +30,6 @@ object TimeDecoder : BinaryDecoder { } } 12.toShort() -> { - val isNegative = buffer.readUnsignedByte() == 1.toShort() val duration = buffer.readUnsignedInt().days + diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimestampDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimestampDecoder.kt index db6704703..50be9f593 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimestampDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/binary/decoder/TimestampDecoder.kt @@ -1,7 +1,7 @@ package com.github.jasync.sql.db.mysql.binary.decoder +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf -import mu.KotlinLogging import java.time.LocalDateTime private val logger = KotlinLogging.logger {} @@ -16,7 +16,10 @@ object TimestampDecoder : BinaryDecoder { buffer.readUnsignedShort(), buffer.readUnsignedByte().toInt(), buffer.readUnsignedByte().toInt(), - 0, 0, 0, 0 + 0, + 0, + 0, + 0 ) 7.toShort() -> LocalDateTime.of( buffer.readUnsignedShort(), diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/DecoderRegistry.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/DecoderRegistry.kt index e7aae1a9e..720935cd9 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/DecoderRegistry.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/DecoderRegistry.kt @@ -38,7 +38,6 @@ class DecoderRegistry(charset: Charset) { private val stringDecoder = StringDecoder(charset) fun binaryDecoderFor(columnType: Int, charsetCode: Int): BinaryDecoder { - return when (columnType) { ColumnTypes.FIELD_TYPE_VARCHAR, ColumnTypes.FIELD_TYPE_JSON, diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLConnectionHandler.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLConnectionHandler.kt index d8ded74d9..f6b3c54c0 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLConnectionHandler.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLConnectionHandler.kt @@ -38,6 +38,7 @@ import com.github.jasync.sql.db.util.length import com.github.jasync.sql.db.util.onFailure import com.github.jasync.sql.db.util.tail import com.github.jasync.sql.db.util.toCompletableFuture +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.bootstrap.Bootstrap import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled @@ -49,7 +50,6 @@ import io.netty.channel.ChannelOption import io.netty.channel.EventLoopGroup import io.netty.channel.SimpleChannelInboundHandler import io.netty.handler.codec.CodecException -import mu.KotlinLogging import java.nio.ByteBuffer import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor @@ -215,6 +215,12 @@ class MySQLConnectionHandler( } @Suppress("OverridingDeprecatedMember") + // /** + // * Calls {@link ChannelHandlerContext#fireExceptionCaught(Throwable)} to forward + // * to the next {@link ChannelHandler} in the {@link ChannelPipeline}. + // * + // * Sub-classes may override this method to change behavior. + // */ override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) { // unwrap CodecException if needed when (cause) { diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoder.kt index 1c92570fe..9e0cc2f09 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoder.kt @@ -25,10 +25,10 @@ import com.github.jasync.sql.db.mysql.message.server.ServerMessage import com.github.jasync.sql.db.util.BufferDumper import com.github.jasync.sql.db.util.ByteBufferUtils.read3BytesInt import com.github.jasync.sql.db.util.readBinaryLength +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.ByteToMessageDecoder -import mu.KotlinLogging import java.nio.charset.Charset import java.util.concurrent.atomic.AtomicInteger @@ -65,7 +65,6 @@ class MySQLFrameDecoder(val charset: Charset, private val connectionId: String) override fun decode(ctx: ChannelHandlerContext, buffer: ByteBuf, out: MutableList) { if (buffer.readableBytes() > 4) { - buffer.markReaderIndex() val size = read3BytesInt(buffer) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLOneToOneEncoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLOneToOneEncoder.kt index bff1fc7c7..0deb61c5b 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLOneToOneEncoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/MySQLOneToOneEncoder.kt @@ -14,10 +14,10 @@ import com.github.jasync.sql.db.mysql.message.client.ClientMessage import com.github.jasync.sql.db.mysql.util.CharsetMapper import com.github.jasync.sql.db.util.BufferDumper import com.github.jasync.sql.db.util.ByteBufferUtils +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.MessageToMessageEncoder -import mu.KotlinLogging import java.nio.charset.Charset class MySQLOneToOneEncoder(charset: Charset, charsetMapper: CharsetMapper) : diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/SendLongDataEncoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/SendLongDataEncoder.kt index 8f043ec71..ac18ced6c 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/SendLongDataEncoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/codec/SendLongDataEncoder.kt @@ -3,10 +3,10 @@ package com.github.jasync.sql.db.mysql.codec import com.github.jasync.sql.db.mysql.message.client.ClientMessage import com.github.jasync.sql.db.mysql.message.client.SendLongDataMessage import com.github.jasync.sql.db.util.ByteBufferUtils +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.Unpooled import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.MessageToMessageEncoder -import mu.KotlinLogging private val logger = KotlinLogging.logger {} diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/column/TimeDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/column/TimeDecoder.kt index a09812d84..0fc62ec49 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/column/TimeDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/column/TimeDecoder.kt @@ -11,7 +11,6 @@ import java.time.Duration object TimeDecoder : ColumnDecoder { override fun decode(value: String): Duration { - val pieces = value.split(':') val secondsAndMillis = pieces[2].split('.') diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthMoreDataDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthMoreDataDecoder.kt index 32c069e7f..5a7911264 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthMoreDataDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthMoreDataDecoder.kt @@ -7,7 +7,7 @@ import io.netty.buffer.ByteBuf class AuthMoreDataDecoder : MessageDecoder { override fun decode(buffer: ByteBuf): ServerMessage { return AuthMoreDataMessage( - data = buffer.readByte(), + data = buffer.readByte() ) } } diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthenticationSwitchRequestDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthenticationSwitchRequestDecoder.kt index 97c0840e7..3f8561fd2 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthenticationSwitchRequestDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/AuthenticationSwitchRequestDecoder.kt @@ -12,11 +12,15 @@ class AuthenticationSwitchRequestDecoder(val charset: Charset) : MessageDecoder val method = buffer.readCString(charset) val bytes: Int = buffer.readableBytes() val terminal = 0.toByte() - val seed = if (bytes > 0 && buffer.getByte(buffer.writerIndex() - 1) == terminal) ByteBufUtil.getBytes( - buffer, - buffer.readerIndex(), - bytes - 1 - ) else ByteBufUtil.getBytes(buffer) + val seed = if (bytes > 0 && buffer.getByte(buffer.writerIndex() - 1) == terminal) { + ByteBufUtil.getBytes( + buffer, + buffer.readerIndex(), + bytes - 1 + ) + } else { + ByteBufUtil.getBytes(buffer) + } buffer.skipBytes(bytes) return AuthenticationSwitchRequest(method, seed) } diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ColumnDefinitionDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ColumnDefinitionDecoder.kt index e53fba2df..0d6605d51 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ColumnDefinitionDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ColumnDefinitionDecoder.kt @@ -10,7 +10,6 @@ import java.nio.charset.Charset class ColumnDefinitionDecoder(val charset: Charset, val registry: DecoderRegistry) : MessageDecoder { override fun decode(buffer: ByteBuf): ColumnDefinitionMessage { - val catalog = buffer.readLengthEncodedString(charset) val schema = buffer.readLengthEncodedString(charset) val table = buffer.readLengthEncodedString(charset) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ErrorDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ErrorDecoder.kt index a7670fe77..ed549622c 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ErrorDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/ErrorDecoder.kt @@ -10,7 +10,6 @@ import java.nio.charset.Charset class ErrorDecoder(val charset: Charset) : MessageDecoder { override fun decode(buffer: ByteBuf): ServerMessage { - return ErrorMessage( buffer.readShort().toInt(), buffer.readFixedString(6, charset), diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/HandshakeV10Decoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/HandshakeV10Decoder.kt index 73a2fa77d..b8d57b09a 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/HandshakeV10Decoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/HandshakeV10Decoder.kt @@ -7,9 +7,9 @@ import com.github.jasync.sql.db.mysql.util.CapabilityFlag.CLIENT_PLUGIN_AUTH import com.github.jasync.sql.db.mysql.util.CapabilityFlag.CLIENT_SECURE_CONNECTION import com.github.jasync.sql.db.util.readCString import com.github.jasync.sql.db.util.readUntilEOF +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.util.CharsetUtil -import mu.KotlinLogging import kotlin.experimental.and private val logger = KotlinLogging.logger {} @@ -24,7 +24,6 @@ class HandshakeV10Decoder : MessageDecoder { } override fun decode(buffer: ByteBuf): ServerMessage { - val serverVersion = buffer.readCString(ASCII) val connectionId = buffer.readUnsignedInt() diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/OkDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/OkDecoder.kt index f8112ee4c..c30655cfa 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/OkDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/OkDecoder.kt @@ -10,7 +10,6 @@ import java.nio.charset.Charset class OkDecoder(val charset: Charset) : MessageDecoder { override fun decode(buffer: ByteBuf): ServerMessage { - return OkMessage( affectedRows = buffer.readBinaryLength(), lastInsertId = buffer.readBinaryLength(), diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/PreparedStatementPrepareResponseDecoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/PreparedStatementPrepareResponseDecoder.kt index d0cf037e3..40d9a6381 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/PreparedStatementPrepareResponseDecoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/decoder/PreparedStatementPrepareResponseDecoder.kt @@ -3,15 +3,14 @@ package com.github.jasync.sql.db.mysql.decoder import com.github.jasync.sql.db.mysql.message.server.PreparedStatementPrepareResponse import com.github.jasync.sql.db.mysql.message.server.ServerMessage import com.github.jasync.sql.db.util.BufferDumper.dumpAsHex +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf -import mu.KotlinLogging private val logger = KotlinLogging.logger {} class PreparedStatementPrepareResponseDecoder : MessageDecoder { override fun decode(buffer: ByteBuf): ServerMessage { - logger.trace { "prepared statement response dump is \n${dumpAsHex(buffer)}" } val statementId = ByteArray(4) { buffer.readByte() } diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/AuthenticationSwitchResponseEncoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/AuthenticationSwitchResponseEncoder.kt index f470d99b8..ffdcda4fb 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/AuthenticationSwitchResponseEncoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/AuthenticationSwitchResponseEncoder.kt @@ -25,7 +25,7 @@ class AuthenticationSwitchResponseEncoder(val charset: Charset) : MessageEncoder switch.password, switch.request.seed, switch.sslConfiguration, - switch.rsaPublicKey, + switch.rsaPublicKey ) buffer.writeBytes(bytes) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/HandshakeResponseEncoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/HandshakeResponseEncoder.kt index 6054ef52d..e7646d1cf 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/HandshakeResponseEncoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/HandshakeResponseEncoder.kt @@ -47,7 +47,7 @@ class HandshakeResponseEncoder(private val charset: Charset, private val headerE if (m.appName != null) { // CONNECTION_ATTRS val byteWidthEvaluator = { - value: Int -> + value: Int -> when { value < 251 -> 1 value < (1 shl 16) -> 3 diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/PreparedStatementExecuteEncoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/PreparedStatementExecuteEncoder.kt index 8859bfe78..e3bef1d81 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/PreparedStatementExecuteEncoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/PreparedStatementExecuteEncoder.kt @@ -61,7 +61,8 @@ class PreparedStatementExecuteEncoder(private val rowEncoder: BinaryRowEncoder) fun encodeValue(parameterTypesBuffer: ByteBuf, parameterValuesBuffer: ByteBuf, value: Any, includeValue: Boolean) { val encoder = rowEncoder.encoderFor(value) parameterTypesBuffer.writeShort(encoder.encodesTo()) - if (includeValue) + if (includeValue) { encoder.encode(value, parameterValuesBuffer) + } } } diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/QueryMessageEncoder.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/QueryMessageEncoder.kt index ee84a8b77..672f32060 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/QueryMessageEncoder.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/QueryMessageEncoder.kt @@ -9,7 +9,6 @@ import java.nio.charset.Charset class QueryMessageEncoder(val charset: Charset) : MessageEncoder { override fun encode(message: ClientMessage): ByteBuf { - val m = message as QueryMessage val encodedQuery = m.query.toByteArray(charset) val buffer = ByteBufferUtils.packetBuffer(4 + 1 + encodedQuery.size) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationMethod.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationMethod.kt index 3ba84cfab..c7b9e0db9 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationMethod.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationMethod.kt @@ -11,7 +11,7 @@ interface AuthenticationMethod { password: String?, seed: ByteArray, sslConfiguration: SSLConfiguration, - rsaPublicKey: Path?, + rsaPublicKey: Path? ): ByteArray companion object { @@ -24,7 +24,7 @@ interface AuthenticationMethod { CachingSha2 to CachingSha2PasswordAuthentication, Native to MySQLNativePasswordAuthentication, Old to OldPasswordAuthentication, - Sha256 to Sha256PasswordAuthentication, + Sha256 to Sha256PasswordAuthentication ) } } diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationScrambler.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationScrambler.kt index a43132ca4..33675104b 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationScrambler.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/AuthenticationScrambler.kt @@ -11,7 +11,7 @@ object AuthenticationScrambler { password: String, charset: Charset, seed: ByteArray, - seedFirst: Boolean, + seedFirst: Boolean ): ByteArray { val messageDigest = MessageDigest.getInstance(algorithm) val initialDigest = messageDigest.digest(password.toByteArray(charset)) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/CachingSha2PasswordAuthentication.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/CachingSha2PasswordAuthentication.kt index dcacae2c1..d47d71062 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/CachingSha2PasswordAuthentication.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/CachingSha2PasswordAuthentication.kt @@ -13,7 +13,7 @@ object CachingSha2PasswordAuthentication : AuthenticationMethod { password: String?, seed: ByteArray, sslConfiguration: SSLConfiguration, - rsaPublicKey: Path?, + rsaPublicKey: Path? ): ByteArray { return if (password != null) { AuthenticationScrambler.scramble411("SHA-256", password, charset, seed, false) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/MySQLNativePasswordAuthentication.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/MySQLNativePasswordAuthentication.kt index 6101c6b8b..7efa9c59b 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/MySQLNativePasswordAuthentication.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/MySQLNativePasswordAuthentication.kt @@ -13,7 +13,7 @@ object MySQLNativePasswordAuthentication : AuthenticationMethod { password: String?, seed: ByteArray, sslConfiguration: SSLConfiguration, - rsaPublicKey: Path?, + rsaPublicKey: Path? ): ByteArray { return if (password != null) { AuthenticationScrambler.scramble411("SHA-1", password, charset, seed, true) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/OldPasswordAuthentication.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/OldPasswordAuthentication.kt index 199c7e98d..638865e9f 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/OldPasswordAuthentication.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/OldPasswordAuthentication.kt @@ -16,7 +16,7 @@ object OldPasswordAuthentication : AuthenticationMethod { password: String?, seed: ByteArray, sslConfiguration: SSLConfiguration, - rsaPublicKey: Path?, + rsaPublicKey: Path? ): ByteArray { return when { !password.isNullOrEmpty() -> { diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/Sha256PasswordAuthentication.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/Sha256PasswordAuthentication.kt index a9c618ca6..efd6d55a1 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/Sha256PasswordAuthentication.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/encoder/auth/Sha256PasswordAuthentication.kt @@ -2,7 +2,7 @@ package com.github.jasync.sql.db.mysql.encoder.auth import com.github.jasync.sql.db.SSLConfiguration import com.github.jasync.sql.db.util.length -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.nio.charset.Charset import java.nio.file.Files import java.nio.file.Path @@ -25,7 +25,7 @@ object Sha256PasswordAuthentication : AuthenticationMethod { password: String?, seed: ByteArray, sslConfiguration: SSLConfiguration, - rsaPublicKey: Path?, + rsaPublicKey: Path? ): ByteArray { if (password == null) { return EmptyArray diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/AuthenticationSwitchResponse.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/AuthenticationSwitchResponse.kt index ffd6d222c..0ff1ab5c8 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/AuthenticationSwitchResponse.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/AuthenticationSwitchResponse.kt @@ -8,5 +8,5 @@ data class AuthenticationSwitchResponse( val password: String?, val sslConfiguration: SSLConfiguration, val rsaPublicKey: Path?, - val request: AuthenticationSwitchRequest, + val request: AuthenticationSwitchRequest ) : ClientMessage(AuthSwitchResponse) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/HandshakeResponseMessage.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/HandshakeResponseMessage.kt index 291f23262..76badacab 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/HandshakeResponseMessage.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/client/HandshakeResponseMessage.kt @@ -15,5 +15,5 @@ data class HandshakeResponseMessage( val database: String? = null, val appName: String? = null, val sslConfiguration: SSLConfiguration, - val rsaPublicKey: Path? = null, + val rsaPublicKey: Path? = null ) : ClientMessage(ClientProtocolVersion) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthMoreDataMessage.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthMoreDataMessage.kt index dfeaa4de7..b40ffb1a8 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthMoreDataMessage.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthMoreDataMessage.kt @@ -1,7 +1,7 @@ package com.github.jasync.sql.db.mysql.message.server data class AuthMoreDataMessage( - val data: Byte, + val data: Byte ) : ServerMessage(AuthMoreData) { fun isSuccess(): Boolean { return data == 3.toByte() diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthenticationSwitchRequest.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthenticationSwitchRequest.kt index 33dfe8371..1ce19004f 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthenticationSwitchRequest.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/message/server/AuthenticationSwitchRequest.kt @@ -2,5 +2,5 @@ package com.github.jasync.sql.db.mysql.message.server data class AuthenticationSwitchRequest( val method: String, - val seed: ByteArray, + val seed: ByteArray ) : ServerMessage(ServerMessage.EOF) diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactory.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactory.kt index 00fd3f798..851a1df59 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactory.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactory.kt @@ -3,7 +3,7 @@ package com.github.jasync.sql.db.mysql.pool import com.github.jasync.sql.db.Configuration import com.github.jasync.sql.db.mysql.MySQLConnection import com.github.jasync.sql.db.pool.ConnectionFactory -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.CompletableFuture private val logger = KotlinLogging.logger {} diff --git a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/util/CapabilityFlag.kt b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/util/CapabilityFlag.kt index 61a9e669c..2c66d44b7 100644 --- a/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/util/CapabilityFlag.kt +++ b/mysql-async/src/main/java/com/github/jasync/sql/db/mysql/util/CapabilityFlag.kt @@ -11,5 +11,5 @@ enum class CapabilityFlag(val value: Int) { CLIENT_PLUGIN_AUTH(0x00080000), CLIENT_SECURE_CONNECTION(0x00008000), CLIENT_CONNECT_ATTRS(0x00100000), - CLIENT_SSL(0x00000800), + CLIENT_SSL(0x00000800) } diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/AuthenticationSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/AuthenticationSpec.kt index 4e57f8cb1..cef8aaa66 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/AuthenticationSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/AuthenticationSpec.kt @@ -158,14 +158,14 @@ class AuthenticationSpec { password: String, sslConfiguration: SSLConfiguration = SSLConfiguration(Mode.Disable), rsaPublicKey: Path? = null, - fn: (MySQLConnection) -> T, + fn: (MySQLConnection) -> T ): T { val configuration = Configuration( username = username, password = password, port = container.firstMappedPort, ssl = sslConfiguration, - rsaPublicKey = rsaPublicKey, + rsaPublicKey = rsaPublicKey ) val connection = MySQLConnection(configuration) diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BinaryColumnsSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BinaryColumnsSpec.kt index e70c98f40..88818c8ef 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BinaryColumnsSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BinaryColumnsSpec.kt @@ -14,7 +14,6 @@ class BinaryColumnsSpec : ConnectionHelper() { @Test fun `correctly load fields as byte arrays`() { - val create = """CREATE TEMPORARY TABLE t ( id BIGINT NOT NULL AUTO_INCREMENT, uuid BINARY(36) NOT NULL, @@ -51,7 +50,6 @@ class BinaryColumnsSpec : ConnectionHelper() { @Test fun `support BINARY type`() { - val create = """CREATE TEMPORARY TABLE POSTS ( id INT NOT NULL AUTO_INCREMENT, @@ -76,7 +74,6 @@ class BinaryColumnsSpec : ConnectionHelper() { @Test fun `support VARBINARY type`() { - val create = """CREATE TEMPORARY TABLE POSTS ( id INT NOT NULL AUTO_INCREMENT, varbinary_column VARBINARY(20), diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BitSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BitSpec.kt index 0b704a5ed..dc1c440ee 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BitSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/BitSpec.kt @@ -8,7 +8,6 @@ class BitSpec : ConnectionHelper() { @Test fun `result in binary data`() { - withConnection { connection -> val create = """CREATE TEMPORARY TABLE binary_test ( @@ -36,7 +35,6 @@ class BitSpec : ConnectionHelper() { @Test fun `result in binary data in BIT(2) column`() { - withConnection { connection -> val create = """CREATE TEMPORARY TABLE binary_test ( diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConcurrentlyRunTest.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConcurrentlyRunTest.kt index 9dffdd847..432e6d2a3 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConcurrentlyRunTest.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConcurrentlyRunTest.kt @@ -1,7 +1,7 @@ package com.github.jasync.sql.db.mysql import com.github.jasync.sql.db.RowData -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.atomic.AtomicInteger private val logger = KotlinLogging.logger {} @@ -13,7 +13,6 @@ object ConcurrentlyRunTest : ConnectionHelper(), Runnable { @JvmStatic fun main(args: Array) { - logger.info("Starting executing code") val threads = 1.until(10).map { Thread(this) } diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConnectionHelper.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConnectionHelper.kt index 0e382fafb..8228bc94f 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConnectionHelper.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ConnectionHelper.kt @@ -98,7 +98,6 @@ open class ConnectionHelper : ContainerHelper() { } fun withConfigurablePool(configuration: Configuration, f: (ConnectionPool) -> T): T { - val poolConfiguration = ConnectionPoolConfiguration( host = configuration.host, port = configuration.port, diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ExecuteManyQueriesSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ExecuteManyQueriesSpec.kt index 933766977..63f4bf5a5 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ExecuteManyQueriesSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ExecuteManyQueriesSpec.kt @@ -8,7 +8,6 @@ class ExecuteManyQueriesSpec : ConnectionHelper() { @Test fun `execute many queries one after the other`() { - withConnection { connection -> (1..500).forEach { _ -> val rows = assertNotNull(executeQuery(connection, "SELECT 6578, 'this is some text'").rows) diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/MySQLConnectionSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/MySQLConnectionSpec.kt index cec6f4684..7e25e94f5 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/MySQLConnectionSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/MySQLConnectionSpec.kt @@ -16,7 +16,6 @@ class MySQLConnectionSpec : ConnectionHelper() { @Test fun `connect should return with timeout exception after create timeout`() { - class MySQLSlowConnectionDelegate( private val delegate: MySQLHandlerDelegate, private val onOkSlowdownInMillis: Int @@ -82,7 +81,6 @@ class MySQLConnectionSpec : ConnectionHelper() { @Test fun `connect to a MySQL instance without a database`() { - val configurationWithoutDatabase = Configuration( "mysql_async_nopw", "localhost", diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/PreparedStatementsSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/PreparedStatementsSpec.kt index 7f0dde158..70b5169ec 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/PreparedStatementsSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/PreparedStatementsSpec.kt @@ -21,7 +21,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `be able to execute prepared statements`() { - withConnection { connection -> val result = assertNotNull(executePreparedStatement(connection, "select 1 as id , 'joe' as name").rows) assertEquals(1, result.size) @@ -37,7 +36,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `be able to detect a null value()a prepared statement`() { - withConnection { connection -> val result = assertNotNull( executePreparedStatement( @@ -54,7 +52,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `be able to select numbers and process them`() { - withConnection { connection -> executeQuery(connection, createTableNumericColumns) executeQuery(connection, insertTableNumericColumns) @@ -74,7 +71,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `be able to select from a table with timestamps`() { - withConnection { connection -> executeQuery(connection, createTableTimeColumns) executeQuery(connection, insertTableTimeColumns) @@ -116,7 +112,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `it should be able to bind statement values to the prepared statement`() { - withConnection { connection -> val insert = """ @@ -181,7 +176,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `bind parameters on a prepared statement`() { - val create = """CREATE TEMPORARY TABLE posts ( id INT NOT NULL AUTO_INCREMENT, some_text TEXT not null, @@ -207,7 +201,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `bind timestamp parameters to a table`() { - val insert = """ insert into posts (created_at_date, created_at_datetime, created_at_timestamp, created_at_time, created_at_year) @@ -244,7 +237,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `read a timestamp with microseconds`() { - val create = """CREATE TEMPORARY TABLE posts ( id INT NOT NULL AUTO_INCREMENT, @@ -284,7 +276,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `support prepared statement with a big string`() { - val bigString: String val builder = StringBuilder() (0..400).map { builder.append("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789") } @@ -363,7 +354,6 @@ class PreparedStatementsSpec : ConnectionHelper() { @Test fun `bind parameters on a prepared statement with limit`() { - val create = """CREATE TEMPORARY TABLE posts ( id INT NOT NULL AUTO_INCREMENT, some_text TEXT not null, diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/QuerySpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/QuerySpec.kt index 569e7f563..fe88a8362 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/QuerySpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/QuerySpec.kt @@ -53,7 +53,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should be able to select from a table`() { - withConnection { connection -> assertThat(executeQuery(connection, this.createTable).rowsAffected).isEqualTo(0) assertThat(executeQuery(connection, this.insert).rowsAffected).isEqualTo(1) @@ -83,7 +82,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should be able to select from a table - validate columnNames()`() { - withConnection { connection -> assertThat(executeQuery(connection, this.createTable).rowsAffected).isEqualTo(0) assertThat(executeQuery(connection, this.insert).rowsAffected).isEqualTo(1) @@ -95,7 +93,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should be able to select from a table with timestamps`() { - withConnection { connection -> executeQuery(connection, createTableTimeColumns) executeQuery(connection, insertTableTimeColumns) @@ -139,7 +136,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should be able to select from a table with the various numeric types`() { - withConnection { connection -> executeQuery(connection, createTableNumericColumns) executeQuery(connection, insertTableNumericColumns) @@ -178,7 +174,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should have column names on result set`() { - val create = """CREATE TEMPORARY TABLE posts ( | id INT NOT NULL AUTO_INCREMENT, | some_bytes BLOB not null, @@ -219,7 +214,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should support BIT type`() { - val create = """CREATE TEMPORARY TABLE POSTS ( | id INT NOT NULL AUTO_INCREMENT, @@ -244,7 +238,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should fail if number of args required is different than the number of provided parameters`() { - withConnection { connection -> verifyException(InsufficientParametersException::class.java) { executePreparedStatement( @@ -277,7 +270,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should select from an empty table with many columns`() { - withConnection { connection -> val create = """create temporary table test_10 ( @@ -297,7 +289,6 @@ class QuerySpec : ConnectionHelper() { @Test fun `connection should select from a json column`() { - val create = "create temporary table jsons (id char(4), data json)" val insert = """ insert jsons values diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/TransactionSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/TransactionSpec.kt index 258f30447..4f0d23925 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/TransactionSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/TransactionSpec.kt @@ -53,7 +53,6 @@ class TransactionSpec : ConnectionHelper() { @Test fun `connection in transaction should correctly rollback changes if the transaction raises an exception`() { - withConnection { connection -> executeQuery(connection, this.createTable) executeQuery(connection, this.insert) @@ -78,7 +77,6 @@ class TransactionSpec : ConnectionHelper() { @Test fun `connection in transaction should should make a connection invalid and not return it to the pool if it raises an exception`() { - withPool { pool -> executeQuery(pool, this.createTable) @@ -99,7 +97,6 @@ class TransactionSpec : ConnectionHelper() { @Test fun `connection in transaction should runs commands for a transaction in a single connection`() { - val id = UUID.randomUUID().toString() withPool { pool -> @@ -125,7 +122,6 @@ class TransactionSpec : ConnectionHelper() { @Test fun `check auto-commit and in transaction flag`() { - withConnection { connection -> assertThat(connection.isAutoCommit()).isTrue() awaitFuture(connection.sendQuery("SET AUTOCOMMIT=0")) diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ZeroDatesSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ZeroDatesSpec.kt index 6ebd6a5bf..ccf1b1df0 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ZeroDatesSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/ZeroDatesSpec.kt @@ -34,7 +34,6 @@ class ZeroDatesSpec : ConnectionHelper() { @Test fun `correctly parse the MySQL zeroed dates as NULL values in text protocol`() { - withConnection { connection -> executeQuery( connection, @@ -48,7 +47,6 @@ class ZeroDatesSpec : ConnectionHelper() { @Test fun `correctly parse the MySQL zeroed dates as NULL values in binary protocol`() { - withConnection { connection -> executeQuery( connection, diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoderSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoderSpec.kt index 858bbec20..c67d6f180 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoderSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/binary/BinaryRowDecoderSpec.kt @@ -32,7 +32,6 @@ class BinaryRowDecoderSpec { @Test fun `decoder a long and a string from the byte array`() { - @Suppress("DEPRECATION") val buffer = Unpooled.wrappedBuffer(idAndName).order(ByteOrder.LITTLE_ENDIAN) val result = decoder.decode(buffer, idAndNameColumns) diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoderSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoderSpec.kt index 9e8257279..3750de787 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoderSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/codec/MySQLFrameDecoderSpec.kt @@ -74,7 +74,6 @@ class MySQLFrameDecoderSpec { @Test fun `on query process it should correctly send an error`() { - val decoder = MySQLFrameDecoder(charset, "[mysql-connection]") decoder.hasDoneHandshake = true val embedder = EmbeddedChannel(decoder) @@ -97,7 +96,6 @@ class MySQLFrameDecoderSpec { @Test fun `on query process it should correctly handle a result set`() { - val decoder = MySQLFrameDecoder(charset, "[mysql-connection]") decoder.hasDoneHandshake = true val embedder = EmbeddedChannel(decoder) diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/column/TimeDecoderSpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/column/TimeDecoderSpec.kt index 82e0cba97..ad0c8bec8 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/column/TimeDecoderSpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/column/TimeDecoderSpec.kt @@ -8,7 +8,6 @@ class TimeDecoderSpec { @Test fun `handle a time`() { - val time = "120:10:07" val duration = Duration.ofHours(120) + Duration.ofMinutes(10) + Duration.ofSeconds(7) assertEquals(duration, TimeDecoder.decode(time)) @@ -16,7 +15,6 @@ class TimeDecoderSpec { @Test fun `handle a time with millis`() { - val time = "120:10:07.00098" val duration = Duration.ofHours(120) + Duration.ofMinutes(10) + Duration.ofSeconds(7) + Duration.ofMillis(98) assertEquals(duration, TimeDecoder.decode(time)) diff --git a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactorySpec.kt b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactorySpec.kt index 8390126df..a3558218a 100644 --- a/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactorySpec.kt +++ b/mysql-async/src/test/java/com/github/jasync/sql/db/mysql/pool/MySQLConnectionFactorySpec.kt @@ -86,7 +86,6 @@ class MySQLConnectionFactorySpec : ConnectionHelper() { @Test fun `test a valid connection and say it is ok`() { - val connection = factory.create().get() val future = factory.test(connection) diff --git a/pool-async/build.gradle.kts b/pool-async/build.gradle.kts index b663a12dd..29ad74728 100644 --- a/pool-async/build.gradle.kts +++ b/pool-async/build.gradle.kts @@ -12,9 +12,9 @@ val AWAITILITY_VERSION: String by project dependencies { api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") api("org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION") - compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") implementation("org.slf4j:slf4j-api:$SL4J_VERSION") - implementation("io.github.microutils:kotlin-logging:$KOTLIN_LOGGING_VERSION") + implementation("io.github.oshai:kotlin-logging-jvm:$KOTLIN_LOGGING_VERSION") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$KOTLIN_COROUTINES_VERSION") testImplementation("junit:junit:$JUNIT_VERSION") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION") diff --git a/pool-async/src/main/java/com/github/jasync/sql/db/pool/ActorBasedObjectPool.kt b/pool-async/src/main/java/com/github/jasync/sql/db/pool/ActorBasedObjectPool.kt index 971ddd51f..794cd1a5b 100644 --- a/pool-async/src/main/java/com/github/jasync/sql/db/pool/ActorBasedObjectPool.kt +++ b/pool-async/src/main/java/com/github/jasync/sql/db/pool/ActorBasedObjectPool.kt @@ -8,13 +8,13 @@ import com.github.jasync.sql.db.util.failed import com.github.jasync.sql.db.util.map import com.github.jasync.sql.db.util.mapTry import com.github.jasync.sql.db.util.onComplete +import io.github.oshai.kotlinlogging.KotlinLogging import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.SupervisorJob import kotlinx.coroutines.cancel import kotlinx.coroutines.channels.SendChannel import kotlinx.coroutines.channels.actor -import mu.KotlinLogging import java.util.LinkedList import java.util.Queue import java.util.WeakHashMap @@ -91,6 +91,15 @@ internal constructor( return future } + override fun softEvict(): CompletableFuture> { + val future = CompletableFuture() + val offered = actor.trySend(SoftEvictAll(future)).isSuccess + if (!offered) { + future.completeExceptionally(Exception("could not offer to actor")) + } + return future.map { this } + } + override fun giveBack(item: T): CompletableFuture> { val future = CompletableFuture() val offered = actor.trySend(GiveBack(item, future)).isSuccess @@ -166,6 +175,7 @@ private sealed class ActorObjectPoolMessage { } private class Take(val future: CompletableFuture) : ActorObjectPoolMessage() +private class SoftEvictAll(val future: CompletableFuture) : ActorObjectPoolMessage() private class GiveBack( val returnedItem: T, val future: CompletableFuture, @@ -174,16 +184,19 @@ private class GiveBack( ) : ActorObjectPoolMessage() { override fun toString(): String { return "GiveBack: ${returnedItem.id} hasError=" + - if (exception != null) + if (exception != null) { "${exception.javaClass.simpleName} - ${exception.message}" - else "false" + } else { + "false" + } } } private class Created( val itemCreateId: Int, val item: Try, - val takeAskFuture: CompletableFuture? + val takeAskFuture: CompletableFuture?, + val objectHolder: ObjectHolder> ) : ActorObjectPoolMessage() { override fun toString(): String { val id = when (item) { @@ -227,6 +240,7 @@ private class ObjectPoolActor( when (message) { is Take -> handleTake(message) is GiveBack -> handleGiveBack(message) + is SoftEvictAll -> handleSoftEvictAll(message) is Created -> handleCreated(message) is TestPoolItems -> handleTestPoolItems() is Close -> handleClose(message) @@ -235,6 +249,19 @@ private class ObjectPoolActor( scheduleNewItemsIfNeeded() } + private fun handleSoftEvictAll(message: SoftEvictAll) { + evictAvailableItems() + inUseItems.values.forEach { it.markForEviction = true } + inCreateItems.entries.forEach { it.value.markForEviction = true } + logger.trace { "handleSoftEvictAll - done" } + message.future.complete(Unit) + } + + private fun evictAvailableItems() { + availableItems.forEach { it.item.destroy() } + availableItems.clear() + } + private fun scheduleNewItemsIfNeeded() { logger.trace { "scheduleNewItemsIfNeeded - $poolStatusString" } // deal with inconsistency in case we have items but also waiting futures @@ -247,7 +274,7 @@ private class ObjectPoolActor( return } } - // deal with inconsistency in case we have waiting futures, and but we can create new items for them + // deal with inconsistency in case we have waiting futures, but we can create new items for them while (availableItems.isEmpty() && waitingQueue.isNotEmpty() && totalItems < configuration.maxObjects && @@ -273,8 +300,7 @@ private class ObjectPoolActor( try { closed = true channel.close() - availableItems.forEach { it.item.destroy() } - availableItems.clear() + evictAvailableItems() inUseItems.forEach { it.value.cleanedByPool = true it.key.destroy() @@ -368,10 +394,12 @@ private class ObjectPoolActor( logger.trace { "releasing idle item ${item.id}" } item.destroy() } + configuration.maxObjectTtl != null && System.currentTimeMillis() - item.creationTime > configuration.maxObjectTtl -> { logger.trace { "releasing item past ttl ${item.id}" } item.destroy() } + else -> { val test = objectFactory.test(item) inUseItems[item] = ItemInUseHolder(item.id, isInTest = true, testFuture = test) @@ -411,7 +439,7 @@ private class ObjectPoolActor( is Failure -> future.completeExceptionally(message.item.exception) is Success -> { try { - message.item.value.borrowTo(future) + message.item.value.borrowTo(future, markForEviction = message.objectHolder.markForEviction) } catch (e: Exception) { future.completeExceptionally(e) } @@ -420,11 +448,11 @@ private class ObjectPoolActor( } } - private fun T.borrowTo(future: CompletableFuture, validate: Boolean = true) { + private fun T.borrowTo(future: CompletableFuture, validate: Boolean = true, markForEviction: Boolean = false) { if (validate) { validate(this) } - inUseItems[this] = ItemInUseHolder(this.id, isInTest = false) + inUseItems[this] = ItemInUseHolder(this.id, isInTest = false, markForEviction = markForEviction) logger.trace { "borrowed: ${this.id} ; $poolStatusString" } future.complete(this) } @@ -450,6 +478,11 @@ private class ObjectPoolActor( } validate(message.returnedItem) message.future.complete(Unit) + if (removed.markForEviction) { + logger.trace { "GiveBack got item ${message.returnedItem.id} marked for eviction, so destroying it" } + message.returnedItem.destroy() + return + } if (waitingQueue.isEmpty()) { if (availableItems.any { holder -> message.returnedItem === holder.item }) { logger.warn { "trying to give back an item to the pool twice ${message.returnedItem.id}, will ignore that" } @@ -482,8 +515,9 @@ private class ObjectPoolActor( while (availableItems.isNotEmpty()) { val future = message.future val wasBorrowed = borrowFirstAvailableItem(future) - if (wasBorrowed) + if (wasBorrowed) { return + } } // available is empty createNewItemPutInWaitQueue(message) @@ -533,10 +567,11 @@ private class ObjectPoolActor( val created = objectFactory.create() val itemCreateId = createIndex createIndex++ - inCreateItems[itemCreateId] = ObjectHolder(created) + val objectHolder = ObjectHolder(created) + inCreateItems[itemCreateId] = objectHolder logger.trace { "createObject createRequest=$itemCreateId" } created.onComplete { tried -> - offerOrLog(Created(itemCreateId, tried, future)) { + offerOrLog(Created(itemCreateId, tried, future, objectHolder)) { "failed to offer on created item $itemCreateId" } } @@ -558,9 +593,11 @@ private open class PoolObjectHolder( val timeElapsed: Long get() = System.currentTimeMillis() - time } -private class ObjectHolder(val item: T) { +private class ObjectHolder( + val item: T, + var markForEviction: Boolean = false +) { val time = System.currentTimeMillis() - val timeElapsed: Long get() = System.currentTimeMillis() - time } @@ -569,12 +606,13 @@ private data class ItemInUseHolder( val isInTest: Boolean, val testFuture: CompletableFuture? = null, val time: Long = System.currentTimeMillis(), - var cleanedByPool: Boolean = false + var cleanedByPool: Boolean = false, + var markForEviction: Boolean = false ) { val timeElapsed: Long get() = System.currentTimeMillis() - time - @Suppress("unused", "ProtectedInFinal") + @Suppress("unused") protected fun finalize() { if (!cleanedByPool) { logger.warn { "LEAK DETECTED for item $this - $timeElapsed ms since in use" } diff --git a/pool-async/src/main/java/com/github/jasync/sql/db/pool/AsyncObjectPool.kt b/pool-async/src/main/java/com/github/jasync/sql/db/pool/AsyncObjectPool.kt index cd1510ff5..e62ca2e26 100644 --- a/pool-async/src/main/java/com/github/jasync/sql/db/pool/AsyncObjectPool.kt +++ b/pool-async/src/main/java/com/github/jasync/sql/db/pool/AsyncObjectPool.kt @@ -40,6 +40,11 @@ interface AsyncObjectPool { fun giveBack(item: T): CompletableFuture> + /** + * Mark all objects in the pool as invalid. Objects will be evicted when not in use. + */ + fun softEvict(): CompletableFuture> + /** * * Closes this pool and future calls to **take** will cause the Future to raise an diff --git a/pool-async/src/test/java/com/github/jasync/sql/db/pool/AbstractAsyncObjectPoolSpec.kt b/pool-async/src/test/java/com/github/jasync/sql/db/pool/AbstractAsyncObjectPoolSpec.kt index cbedbc8da..fa60d42fe 100644 --- a/pool-async/src/test/java/com/github/jasync/sql/db/pool/AbstractAsyncObjectPoolSpec.kt +++ b/pool-async/src/test/java/com/github/jasync/sql/db/pool/AbstractAsyncObjectPoolSpec.kt @@ -227,9 +227,10 @@ class TestWidgetFactory : override fun destroy(item: Widget) {} override fun validate(item: Widget): Try = Try { - if (item.factory == this) + if (item.factory == this) { item - else + } else { throw IllegalArgumentException("Not our item") + } } } diff --git a/pool-async/src/test/java/com/github/jasync/sql/db/pool/ActorBasedObjectPoolTest.kt b/pool-async/src/test/java/com/github/jasync/sql/db/pool/ActorBasedObjectPoolTest.kt index d3671d751..843d578f5 100644 --- a/pool-async/src/test/java/com/github/jasync/sql/db/pool/ActorBasedObjectPoolTest.kt +++ b/pool-async/src/test/java/com/github/jasync/sql/db/pool/ActorBasedObjectPoolTest.kt @@ -17,8 +17,10 @@ class ActorBasedObjectPoolTest { private val factory = ForTestingMyFactory() private val configuration = PoolConfiguration( - maxObjects = 10, maxQueueSize = Int.MAX_VALUE, - validationInterval = Long.MAX_VALUE, maxIdle = Long.MAX_VALUE, + maxObjects = 10, + maxQueueSize = Int.MAX_VALUE, + validationInterval = Long.MAX_VALUE, + maxIdle = Long.MAX_VALUE, maxObjectTtl = null ) private lateinit var tested: ActorBasedObjectPool @@ -58,7 +60,9 @@ class ActorBasedObjectPoolTest { @Test fun `basic take operation - when create is stuck should be timeout`() { tested = ActorBasedObjectPool( - factory, configuration.copy(createTimeout = 10), false + factory, + configuration.copy(createTimeout = 10), + false ) factory.creationStuck = true val result = tested.take() @@ -70,7 +74,9 @@ class ActorBasedObjectPoolTest { @Test fun `take operation that is waiting in queue - when create is stuck should be timeout`() { tested = ActorBasedObjectPool( - factory, configuration.copy(maxObjects = 1, queryTimeout = 10), false + factory, + configuration.copy(maxObjects = 1, queryTimeout = 10), + false ) // first item is canceled when the create fails tested.take() @@ -90,7 +96,9 @@ class ActorBasedObjectPoolTest { @Test fun `basic take operation - when create is little stuck should not be timeout (create timeout is 5 sec)`() { tested = ActorBasedObjectPool( - factory, configuration.copy(createTimeout = 5000), false + factory, + configuration.copy(createTimeout = 5000), + false ) factory.creationStuckTime = 10 val result = tested.take() @@ -150,6 +158,41 @@ class ActorBasedObjectPoolTest { assertThat(factory.validated).isEqualTo(listOf(result, result, result)) } + @Test + fun `softEviction - basic take-evict-return pool should be empty`() { + tested = createDefaultPool() + val result = tested.take().get() + tested.softEvict().get() + tested.giveBack(result).get() + assertThat(tested.availableItems).isEmpty() + } + + @Test + fun `softEviction - minimum number of objects is maintained, but objects are replaced`() { + tested = ActorBasedObjectPool( + factory, + configuration.copy(minIdleObjects = 3), + false + ) + tested.take().get() + await.untilCallTo { tested.availableItemsSize } matches { it == 3 } + val availableItems = tested.availableItems + tested.softEvict().get() + await.untilCallTo { tested.availableItemsSize } matches { it == 3 } + assertThat(tested.availableItems.toSet().intersect(availableItems.toSet())).isEmpty() + } + + @Test + fun `test for objects in create eviction in case of softEviction`() { + factory.creationStuckTime = 10 + tested = createDefaultPool() + val itemPromise = tested.take() + tested.softEvict().get() + val item = itemPromise.get() + tested.giveBack(item).get() + assertThat(tested.availableItemsSize).isEqualTo(0) + } + @Test fun `take2-return2-take first not validated second is ok should be returned`() { tested = createDefaultPool() diff --git a/postgis-jasync/build.gradle.kts b/postgis-jasync/build.gradle.kts index b2e9887b1..79b504f85 100644 --- a/postgis-jasync/build.gradle.kts +++ b/postgis-jasync/build.gradle.kts @@ -16,18 +16,18 @@ val AWAITILITY_VERSION: String by project val JTS_VERSION: String by project dependencies { - compile(project(":db-async-common")) - compile(project(":pool-async")) - compile(project(":postgresql-async")) - compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") - compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") - compile("org.slf4j:slf4j-api:$SL4J_VERSION") - compile("joda-time:joda-time:$JODA_VERSION") - compile("io.netty:netty-transport:$NETTY_VERSION") - compile("io.netty:netty-handler:$NETTY_VERSION") - compile("io.github.microutils:kotlin-logging:$KOTLIN_LOGGING_VERSION") - compile("com.ongres.scram:client:$SCRAM_CLIENT_VERSION") - compile("org.threeten:threeten-extra:$THREETEN_EXTRA") + api(project(":db-async-common")) + api(project(":pool-async")) + api(project(":postgresql-async")) + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") + api("org.slf4j:slf4j-api:$SL4J_VERSION") + api("joda-time:joda-time:$JODA_VERSION") + api("io.netty:netty-transport:$NETTY_VERSION") + api("io.netty:netty-handler:$NETTY_VERSION") + api("io.github.oshai:kotlin-logging-jvm:$KOTLIN_LOGGING_VERSION") + api("com.ongres.scram:client:$SCRAM_CLIENT_VERSION") + api("org.threeten:threeten-extra:$THREETEN_EXTRA") testImplementation("junit:junit:$JUNIT_VERSION") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION") @@ -37,5 +37,5 @@ dependencies { testImplementation("ch.qos.logback:logback-classic:$LOGBACK_VERSION") testImplementation("org.testcontainers:postgresql:$TEST_CONTAINERS_VERSION") testImplementation("org.awaitility:awaitility-kotlin:$AWAITILITY_VERSION") - compile("org.locationtech.jts:jts-core:$JTS_VERSION") + api("org.locationtech.jts:jts-core:$JTS_VERSION") } diff --git a/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/BinaryParser.kt b/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/BinaryParser.kt index 70d9573a6..a2eb0435a 100644 --- a/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/BinaryParser.kt +++ b/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/BinaryParser.kt @@ -256,8 +256,13 @@ object Geom { val ALLTYPES = arrayOf( "", // internally used LinearRing does not have any text in front of // it - "POINT", "LINESTRING", "POLYGON", "MULTIPOINT", "MULTILINESTRING", - "MULTIPOLYGON", "GEOMETRYCOLLECTION" + "POINT", + "LINESTRING", + "POLYGON", + "MULTIPOINT", + "MULTILINESTRING", + "MULTIPOLYGON", + "GEOMETRYCOLLECTION" ) /** diff --git a/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/JasyncPostgisRegister.kt b/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/JasyncPostgisRegister.kt index efdb56769..16732fe14 100644 --- a/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/JasyncPostgisRegister.kt +++ b/postgis-jasync/src/main/java/com/github/jasync/sql/db/postgis/JasyncPostgisRegister.kt @@ -4,7 +4,7 @@ import com.github.jasync.sql.db.Connection import com.github.jasync.sql.db.postgresql.column.PostgreSQLColumnDecoderRegistry import com.github.jasync.sql.db.util.FP import com.github.jasync.sql.db.util.map -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.CompletableFuture import java.util.concurrent.atomic.AtomicBoolean @@ -19,6 +19,7 @@ private val logger = KotlinLogging.logger {} object JasyncPostgisRegister { val geometryRegistered = AtomicBoolean(false) + @JvmStatic fun init(connection: Connection): CompletableFuture { if (geometryRegistered.get()) { diff --git a/postgis-jasync/src/test/java/ContainerHelper.kt b/postgis-jasync/src/test/java/ContainerHelper.kt index 7825d390b..b5cd89a7f 100644 --- a/postgis-jasync/src/test/java/ContainerHelper.kt +++ b/postgis-jasync/src/test/java/ContainerHelper.kt @@ -2,7 +2,7 @@ package com.github.aysnc.sql.db.integration import com.github.jasync.sql.db.Configuration import com.github.jasync.sql.db.postgresql.PostgreSQLConnection -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.testcontainers.containers.BindMode import org.testcontainers.containers.PostgreSQLContainer import org.testcontainers.utility.DockerImageName diff --git a/postgis-jasync/src/test/java/DatabaseTestHelper.kt b/postgis-jasync/src/test/java/DatabaseTestHelper.kt index 2c24b834f..8e8688b10 100644 --- a/postgis-jasync/src/test/java/DatabaseTestHelper.kt +++ b/postgis-jasync/src/test/java/DatabaseTestHelper.kt @@ -38,7 +38,6 @@ open class DatabaseTestHelper { } fun withHandler(configuration: Configuration, fn: (PostgreSQLConnection) -> T): T { - val handler = PostgreSQLConnection(configuration) try { @@ -65,7 +64,6 @@ open class DatabaseTestHelper { try { return fn() } catch (e: TimeoutException) { - throw IllegalStateException("Timeout executing call from handler -> %s".format(handler)) } } diff --git a/postgresql-async/build.gradle.kts b/postgresql-async/build.gradle.kts index e2e133be0..1e2f5dd51 100644 --- a/postgresql-async/build.gradle.kts +++ b/postgresql-async/build.gradle.kts @@ -15,17 +15,17 @@ val TEST_CONTAINERS_VERSION: String by project val AWAITILITY_VERSION: String by project dependencies { - compile(project(":db-async-common")) - compile(project(":pool-async")) - compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") - compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") - compile("org.slf4j:slf4j-api:$SL4J_VERSION") - compile("joda-time:joda-time:$JODA_VERSION") - compile("io.netty:netty-transport:$NETTY_VERSION") - compile("io.netty:netty-handler:$NETTY_VERSION") - compile("io.github.microutils:kotlin-logging:$KOTLIN_LOGGING_VERSION") - compile("com.ongres.scram:client:$SCRAM_CLIENT_VERSION") - compile("org.threeten:threeten-extra:$THREETEN_EXTRA") + api(project(":db-async-common")) + api(project(":pool-async")) + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$KOTLIN_COROUTINES_VERSION") + api("org.slf4j:slf4j-api:$SL4J_VERSION") + api("joda-time:joda-time:$JODA_VERSION") + api("io.netty:netty-transport:$NETTY_VERSION") + api("io.netty:netty-handler:$NETTY_VERSION") + api("io.github.oshai:kotlin-logging-jvm:$KOTLIN_LOGGING_VERSION") + api("com.ongres.scram:client:$SCRAM_CLIENT_VERSION") + api("org.threeten:threeten-extra:$THREETEN_EXTRA") testImplementation("junit:junit:$JUNIT_VERSION") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$KOTLIN_VERSION") diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/PostgreSQLConnection.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/PostgreSQLConnection.kt index 3f6ba18ab..81ba5e569 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/PostgreSQLConnection.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/PostgreSQLConnection.kt @@ -61,7 +61,7 @@ import com.ongres.scram.client.ScramClient import com.ongres.scram.client.ScramSession import com.ongres.scram.common.exception.ScramException import com.ongres.scram.common.stringprep.StringPreparations -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.time.Duration import java.util.Collections import java.util.Optional @@ -196,14 +196,14 @@ class PostgreSQLConnection @JvmOverloads constructor( this.currentPreparedStatement = Optional.of(holder) this.currentQuery = Optional.of(MutableResultSet(holder.columnDatas)) write( - if (holder.prepared) + if (holder.prepared) { PreparedStatementExecuteMessage( holder.statementId, holder.realQuery, params.values, this.encoderRegistry ) - else { + } else { holder.prepared = true PreparedStatementOpeningMessage( holder.statementId, @@ -382,8 +382,9 @@ class PostgreSQLConnection @JvmOverloads constructor( } fun validateIfItIsReadyForQuery(errorMessage: String) { - if (this.queryPromise().isPresent) + if (this.queryPromise().isPresent) { notReadyForQueryError(errorMessage, false) + } } private fun validateQuery(query: String) { @@ -400,8 +401,9 @@ class PostgreSQLConnection @JvmOverloads constructor( private fun queryPromise(): Optional> = queryPromiseReference.get() private fun setQueryPromise(promise: CompletableFuture) { - if (!this.queryPromiseReference.compareAndSet(Optional.empty(), Optional.of(promise))) + if (!this.queryPromiseReference.compareAndSet(Optional.empty(), Optional.of(promise))) { notReadyForQueryError("Can't run query due to a race , another started query", true) + } } private fun clearQueryPromise(): Optional> { diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageDecoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageDecoder.kt index 7c43104df..0531fa0ac 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageDecoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageDecoder.kt @@ -7,10 +7,10 @@ import com.github.jasync.sql.db.postgresql.messages.backend.ServerMessage import com.github.jasync.sql.db.postgresql.parsers.AuthenticationStartupParser import com.github.jasync.sql.db.postgresql.parsers.MessageParsersRegistry import com.github.jasync.sql.db.util.BufferDumper +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.ByteToMessageDecoder -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} @@ -27,14 +27,12 @@ class MessageDecoder( private var sslChecked = false public override fun decode(ctx: ChannelHandlerContext, b: ByteBuf, out: MutableList) { - if (sslEnabled && !sslChecked) { val code = b.readByte() logger.trace { "Received buffer ${code.toChar()}($code)\n${BufferDumper.dumpAsHex(b)}" } sslChecked = true out.add(SSLResponseMessage(code.toChar() == 'S')) } else if (b.readableBytes() >= 5) { - b.markReaderIndex() val code = b.readByte() @@ -50,7 +48,6 @@ class MessageDecoder( } if (b.readableBytes() >= length) { - logger.trace { "Received buffer ${code.toChar()}($code)\n${BufferDumper.dumpAsHex(b)}" } val result = when (code.toInt()) { diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageEncoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageEncoder.kt index 93bf0d491..505f1edbb 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageEncoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/MessageEncoder.kt @@ -15,9 +15,9 @@ import com.github.jasync.sql.db.postgresql.messages.frontend.ClientMessage import com.github.jasync.sql.db.postgresql.messages.frontend.SSLRequestMessage import com.github.jasync.sql.db.postgresql.messages.frontend.StartupMessage import com.github.jasync.sql.db.util.BufferDumper +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.channel.ChannelHandlerContext import io.netty.handler.codec.MessageToMessageEncoder -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/PostgreSQLConnectionHandler.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/PostgreSQLConnectionHandler.kt index cd1be3041..bd8f77fed 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/PostgreSQLConnectionHandler.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/codec/PostgreSQLConnectionHandler.kt @@ -27,6 +27,7 @@ import com.github.jasync.sql.db.util.onCompleteAsync import com.github.jasync.sql.db.util.onFailure import com.github.jasync.sql.db.util.success import com.github.jasync.sql.db.util.toCompletableFuture +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.bootstrap.Bootstrap import io.netty.channel.Channel import io.netty.channel.ChannelHandlerContext @@ -36,7 +37,6 @@ import io.netty.channel.EventLoopGroup import io.netty.channel.SimpleChannelInboundHandler import io.netty.handler.codec.CodecException import io.netty.handler.ssl.SslHandler -import mu.KotlinLogging import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor @@ -127,10 +127,11 @@ class PostgreSQLConnectionHandler( @Suppress("RedundantUnitReturnType") override fun channelActive(ctx: ChannelHandlerContext) { - if (configuration.ssl.mode == SSLConfiguration.Mode.Disable) + if (configuration.ssl.mode == SSLConfiguration.Mode.Disable) { ctx.writeAndFlush(StartupMessage(this.properties)) - else + } else { ctx.writeAndFlush(SSLRequestMessage) + } } override fun channelRead0(ctx: ChannelHandlerContext?, message: Any) { @@ -221,6 +222,12 @@ class PostgreSQLConnectionHandler( } @Suppress("OverridingDeprecatedMember") + // /** + // * Calls {@link ChannelHandlerContext#fireExceptionCaught(Throwable)} to forward + // * to the next {@link ChannelHandler} in the {@link ChannelPipeline}. + // * + // * Sub-classes may override this method to change behavior. + // */ override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) { // unwrap CodecException if needed when (cause) { diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ArrayDecoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ArrayDecoder.kt index adc7b9d6b..b90cfd1a9 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ArrayDecoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ArrayDecoder.kt @@ -13,7 +13,6 @@ import java.nio.charset.Charset class ArrayDecoder(private val decoder: ColumnDecoder) : ColumnDecoder { override fun decode(kind: ColumnData, value: ByteBuf, charset: Charset): List? { - val bytes = ByteArray(value.readableBytes()) value.readBytes(bytes) val valueString = String(bytes, charset) diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ByteArrayEncoderDecoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ByteArrayEncoderDecoder.kt index 67ea9c857..2c04fc795 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ByteArrayEncoderDecoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ByteArrayEncoderDecoder.kt @@ -12,7 +12,6 @@ object ByteArrayEncoderDecoder : ColumnEncoderDecoder { private val HexStartChars = HexStart.toCharArray() override fun decode(value: String): ByteArray { - return if (value.startsWith(HexStart)) { HexCodec.decode(value, 2) } else { diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ColumnTypes.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ColumnTypes.kt index eba24cb1d..e01b44272 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ColumnTypes.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/ColumnTypes.kt @@ -12,6 +12,7 @@ object ColumnTypes { const val Integer = 23 const val IntegerArray = 1007 const val Numeric = 1700 + // Decimal is the same as Numeric on PostgreSQL const val NumericArray = 1231 const val Real = 700 @@ -22,6 +23,7 @@ object ColumnTypes { const val Bpchar = 1042 const val BpcharArray = 1014 const val Varchar = 1043 + // Char is the same as Varchar on PostgreSQL const val VarcharArray = 1015 const val Text = 25 diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnDecoderRegistry.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnDecoderRegistry.kt index 85e795e4d..39f05f14d 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnDecoderRegistry.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnDecoderRegistry.kt @@ -15,9 +15,9 @@ import com.github.jasync.sql.db.column.TimeEncoderDecoder import com.github.jasync.sql.db.column.TimeWithTimezoneEncoderDecoder import com.github.jasync.sql.db.column.UUIDEncoderDecoder import com.github.jasync.sql.db.general.ColumnData +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.util.CharsetUtil -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnEncoderRegistry.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnEncoderRegistry.kt index 41edd0c7e..ef715e592 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnEncoderRegistry.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLColumnEncoderRegistry.kt @@ -16,8 +16,8 @@ import com.github.jasync.sql.db.column.TimeEncoderDecoder import com.github.jasync.sql.db.column.TimestampEncoderDecoder import com.github.jasync.sql.db.column.TimestampWithTimezoneEncoderDecoder import com.github.jasync.sql.db.column.UUIDEncoderDecoder +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf -import mu.KotlinLogging import org.threeten.extra.PeriodDuration import java.math.BigDecimal import java.nio.ByteBuffer @@ -115,7 +115,6 @@ class PostgreSQLColumnEncoderRegistry : ColumnEncoderRegistry { * Used to encode a value that is not null and not an Option. */ private fun encodeValue(value: Any): String { - val encoder = this.classes[value.javaClass] return if (encoder != null) { diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLIntervalEncoderDecoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLIntervalEncoderDecoder.kt index 826e6329b..80658d575 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLIntervalEncoderDecoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/column/PostgreSQLIntervalEncoderDecoder.kt @@ -79,27 +79,33 @@ object PostgreSQLIntervalEncoderDecoder : ColumnEncoderDecoder { PeriodDuration.parse(value) } else { val format = ( - if (value.startsWith("@ ")) + if (value.startsWith("@ ")) { postgres_verboseParser - else { + } else { /* try to guess based on what comes after the first number */ val i = value.indexOfFirst { !it.isDigit() }.let { if ("-+".contains(value[0])) 1 else 0 } - if (i < 0 || ":.".contains(value[i])) /* simple HMS (to support group negation) */ + if (i < 0 || ":.".contains(value[i])) { + /* simple HMS (to support group negation) */ hmsParser - else if (value[i] == '-') /* sql_standard: Y-M */ + } else if (value[i] == '-') { + /* sql_standard: Y-M */ sqlParser - else if (value[i] == ' ' && i + 1 < value.length && value[i + 1].isDigit()) /* sql_standard: D H:M:S */ + } else if (value[i] == ' ' && i + 1 < value.length && value[i + 1].isDigit()) { + /* sql_standard: D H:M:S */ sqlDTParser - else + } else { postgresParser + } } ) - val jodaPeriod = if ((format == hmsParser) && value.startsWith('-')) + val jodaPeriod = if ((format == hmsParser) && value.startsWith('-')) { format.parsePeriod(value.substring(1)).negated() - else if (value.endsWith(" ago")) /* only really applies to postgres_verbose, but shouldn't hurt */ + } else if (value.endsWith(" ago")) { + /* only really applies to postgres_verbose, but shouldn't hurt */ format.parsePeriod(value.removeSuffix(" ago")).negated() - else + } else { format.parsePeriod(value) + } PeriodDuration.of( Period.of(jodaPeriod.years, jodaPeriod.months, jodaPeriod.days), Duration.ofHours(jodaPeriod.hours.toLong()).plusMinutes(jodaPeriod.minutes.toLong()) diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/CloseStatementEncoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/CloseStatementEncoder.kt index f29b11c83..099f3aa51 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/CloseStatementEncoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/CloseStatementEncoder.kt @@ -2,8 +2,8 @@ package com.github.jasync.sql.db.postgresql.encoders import com.github.jasync.sql.db.postgresql.messages.frontend.ClientMessage import com.github.jasync.sql.db.postgresql.messages.frontend.PreparedStatementCloseMessage +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/ExecutePreparedStatementEncoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/ExecutePreparedStatementEncoder.kt index 531f49caf..f27770f9d 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/ExecutePreparedStatementEncoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/ExecutePreparedStatementEncoder.kt @@ -11,7 +11,6 @@ class ExecutePreparedStatementEncoder(val charset: Charset, val encoder: ColumnE PreparedStatementEncoderHelper { override fun encode(message: ClientMessage): ByteBuf { - val m = message as PreparedStatementExecuteMessage val statementIdBytes = m.statementId.toString().toByteArray(charset) diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementEncoderHelper.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementEncoderHelper.kt index fedec5898..a2ebff94f 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementEncoderHelper.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementEncoderHelper.kt @@ -4,9 +4,9 @@ import com.github.jasync.sql.db.column.ColumnEncoderRegistry import com.github.jasync.sql.db.postgresql.messages.backend.ServerMessage import com.github.jasync.sql.db.util.ByteBufferUtils import com.github.jasync.sql.db.util.length +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} @@ -26,7 +26,6 @@ interface PreparedStatementEncoderHelper { charset: Charset, writeDescribe: Boolean = false ): ByteBuf { - logger.debug { "Preparing execute portal to statement ($query) - values (${values.joinToString(", ")}) - $charset" } val bindBuffer = Unpooled.buffer(1024) @@ -89,6 +88,7 @@ interface PreparedStatementEncoderHelper { if (writeDescribe) { val describeLength = 1 + 4 + 1 + statementIdBytes.length + 1 + @Suppress("UnnecessaryVariable") val describeBuffer = bindBuffer describeBuffer.writeByte(ServerMessage.Describe) diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementOpeningEncoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementOpeningEncoder.kt index 48242ecb1..edae08327 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementOpeningEncoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/PreparedStatementOpeningEncoder.kt @@ -5,9 +5,9 @@ import com.github.jasync.sql.db.postgresql.messages.backend.ServerMessage import com.github.jasync.sql.db.postgresql.messages.frontend.ClientMessage import com.github.jasync.sql.db.postgresql.messages.frontend.PreparedStatementOpeningMessage import com.github.jasync.sql.db.util.ByteBufferUtils +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} @@ -15,7 +15,6 @@ private val logger = KotlinLogging.logger {} class PreparedStatementOpeningEncoder(val charset: Charset, val encoder: ColumnEncoderRegistry) : Encoder, PreparedStatementEncoderHelper { override fun encode(message: ClientMessage): ByteBuf { - val m = message as PreparedStatementOpeningMessage val statementIdBytes = m.statementId.toString().toByteArray(charset) diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/QueryMessageEncoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/QueryMessageEncoder.kt index f4f937a34..22b9f8b1a 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/QueryMessageEncoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/QueryMessageEncoder.kt @@ -4,9 +4,9 @@ import com.github.jasync.sql.db.postgresql.messages.backend.ServerMessage import com.github.jasync.sql.db.postgresql.messages.frontend.ClientMessage import com.github.jasync.sql.db.postgresql.messages.frontend.QueryMessage import com.github.jasync.sql.db.util.ByteBufferUtils +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} @@ -14,7 +14,6 @@ private val logger = KotlinLogging.logger {} class QueryMessageEncoder(val charset: Charset) : Encoder { override fun encode(message: ClientMessage): ByteBuf { - val m = message as QueryMessage logger.debug("Executing direct query ({})", m.query) diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/StartupMessageEncoder.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/StartupMessageEncoder.kt index 13bfe204b..9af48af49 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/StartupMessageEncoder.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/encoders/StartupMessageEncoder.kt @@ -2,9 +2,9 @@ package com.github.jasync.sql.db.postgresql.encoders import com.github.jasync.sql.db.postgresql.messages.frontend.StartupMessage import com.github.jasync.sql.db.util.ByteBufferUtils +import io.github.oshai.kotlinlogging.KotlinLogging import io.netty.buffer.ByteBuf import io.netty.buffer.Unpooled -import mu.KotlinLogging import java.nio.charset.Charset private val logger = KotlinLogging.logger {} @@ -12,7 +12,6 @@ private val logger = KotlinLogging.logger {} class StartupMessageEncoder(val charset: Charset) { fun encode(startup: StartupMessage): ByteBuf { - val buffer = Unpooled.buffer() buffer.writeInt(0) buffer.writeShort(3) diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/InformationParser.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/InformationParser.kt index 9ca119ed0..f48a68c68 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/InformationParser.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/InformationParser.kt @@ -8,7 +8,6 @@ import java.nio.charset.Charset abstract class InformationParser(val charset: Charset) : MessageParser { override fun parseMessage(buffer: ByteBuf): ServerMessage { - val fields = mutableMapOf() while (buffer.isReadable) { val kind = buffer.readByte() diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/RowDescriptionParser.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/RowDescriptionParser.kt index 46da872b3..311debe93 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/RowDescriptionParser.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/parsers/RowDescriptionParser.kt @@ -47,7 +47,6 @@ The format code being used for the field. Currently will be zero (text) or one ( class RowDescriptionParser(val charset: Charset) : MessageParser { override fun parseMessage(buffer: ByteBuf): ServerMessage { - val columnsCount = buffer.readShort() val columns = mutableListOf() diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/pool/PostgreSQLConnectionFactory.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/pool/PostgreSQLConnectionFactory.kt index 83c623a02..8d0778a27 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/pool/PostgreSQLConnectionFactory.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/pool/PostgreSQLConnectionFactory.kt @@ -3,7 +3,7 @@ package com.github.jasync.sql.db.postgresql.pool import com.github.jasync.sql.db.Configuration import com.github.jasync.sql.db.pool.ConnectionFactory import com.github.jasync.sql.db.postgresql.PostgreSQLConnection -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.CompletableFuture private val logger = KotlinLogging.logger {} diff --git a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/util/ArrayStreamingParser.kt b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/util/ArrayStreamingParser.kt index 60249a8f0..5f6c25f81 100644 --- a/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/util/ArrayStreamingParser.kt +++ b/postgresql-async/src/main/java/com/github/jasync/sql/db/postgresql/util/ArrayStreamingParser.kt @@ -6,7 +6,6 @@ import com.github.jasync.sql.db.util.size object ArrayStreamingParser { fun parse(content: String, delegate: ArrayStreamingParserDelegate) { - var index = 0 var escaping = false var quoted = false @@ -71,7 +70,6 @@ object ArrayStreamingParser { } fun sendElementEvent(builder: StringBuilder?, quoted: Boolean, delegate: ArrayStreamingParserDelegate) { - val value = builder.toString() if (!quoted && "NULL".equals(value, ignoreCase = true)) { diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/general/MutableResultSetSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/general/MutableResultSetSpec.kt index 2c999a51b..4f7c14213 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/general/MutableResultSetSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/general/MutableResultSetSpec.kt @@ -22,7 +22,6 @@ class MutableResultSetSpec { @Test fun `result set should correctly map column data to fields`() { - val columns = listOf( create( name = "id", @@ -59,7 +58,6 @@ class MutableResultSetSpec { @Test fun `result set should return the same order as the one given by columns`() { - val columns = listOf( create("id", ColumnTypes.Integer), create("name", ColumnTypes.Varchar), diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ArrayTypesSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ArrayTypesSpec.kt index 2e11f5138..a5128e647 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ArrayTypesSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ArrayTypesSpec.kt @@ -46,7 +46,6 @@ class ArrayTypesSpec : DatabaseTestHelper() { @Test fun `connection should correctly parse the array type`() { - withHandler { handler -> try { executeDdl(handler, simpleCreate("cptat")) @@ -82,7 +81,6 @@ class ArrayTypesSpec : DatabaseTestHelper() { @Test fun `connection should correctly send arrays using prepared statements`() { - val timestamps = listOf( TimestampWithTimezoneEncoderDecoder.decode("2013-04-06 01:15:10.528-03"), TimestampWithTimezoneEncoderDecoder.decode("2013-04-06 01:15:08.528-03") diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/BitSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/BitSpec.kt index b1e4c5240..de77405dd 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/BitSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/BitSpec.kt @@ -8,7 +8,6 @@ class BitSpec : DatabaseTestHelper() { @Test fun `when processing bit columns should result in binary data`() { - withHandler { handler -> val create = """CREATE TEMP TABLE binary_test ( @@ -35,7 +34,6 @@ class BitSpec : DatabaseTestHelper() { @Test fun `when processing bit columns should result in binary data in BIT(2) column`() { - withHandler { handler -> val create = """CREATE TEMP TABLE binary_test ( diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ContainerHelper.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ContainerHelper.kt index 1f2b583e2..a34e31c04 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ContainerHelper.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ContainerHelper.kt @@ -2,7 +2,7 @@ package com.github.aysnc.sql.db.integration import com.github.jasync.sql.db.Configuration import com.github.jasync.sql.db.postgresql.PostgreSQLConnection -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import org.testcontainers.containers.BindMode import org.testcontainers.containers.PostgreSQLContainer import java.util.concurrent.TimeUnit diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/DatabaseTestHelper.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/DatabaseTestHelper.kt index 2c24b834f..8e8688b10 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/DatabaseTestHelper.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/DatabaseTestHelper.kt @@ -38,7 +38,6 @@ open class DatabaseTestHelper { } fun withHandler(configuration: Configuration, fn: (PostgreSQLConnection) -> T): T { - val handler = PostgreSQLConnection(configuration) try { @@ -65,7 +64,6 @@ open class DatabaseTestHelper { try { return fn() } catch (e: TimeoutException) { - throw IllegalStateException("Timeout executing call from handler -> %s".format(handler)) } } diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ListenNotifySpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ListenNotifySpec.kt index 7972af4ef..4d5fceaf0 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ListenNotifySpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/ListenNotifySpec.kt @@ -11,7 +11,6 @@ class ListenNotifySpec : DatabaseTestHelper() { @Test fun `connection should be able to receive a notification if listening`() { - withHandler { connection -> val queue = generateQueueName() @@ -39,7 +38,6 @@ class ListenNotifySpec : DatabaseTestHelper() { @Test fun `connection should be able to receive a notification from a pg_notify call`() { - withHandler { connection -> val queue = generateQueueName() @@ -64,7 +62,6 @@ class ListenNotifySpec : DatabaseTestHelper() { @Test fun `connection should not receive any notification if not registered to the correct channel`() { - withHandler { connection -> val queue = generateQueueName() @@ -91,7 +88,6 @@ class ListenNotifySpec : DatabaseTestHelper() { @Test fun `connection should not receive notifications if cleared the collection`() { - withHandler { connection -> val queue = generateQueueName() @@ -118,7 +114,6 @@ class ListenNotifySpec : DatabaseTestHelper() { @Test fun `connection should not receive notification if listener was removed`() { - withHandler { connection -> val queue = generateQueueName() diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/NumericSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/NumericSpec.kt index cbdb7d98f..27ae1be51 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/NumericSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/NumericSpec.kt @@ -9,7 +9,6 @@ class NumericSpec : DatabaseTestHelper() { @Test fun `when processing numeric columns should support first update of num column with floating`() { - withHandler { handler -> executeDdl(handler, "CREATE TEMP TABLE numeric_test (id BIGSERIAL, numcol NUMERIC)") @@ -28,7 +27,6 @@ class NumericSpec : DatabaseTestHelper() { @Ignore("this test fail since always, see https://github.com/jasync-sql/jasync-sql/issues/15 and https://github.com/mauricio/postgresql-async/blob/b96aaf163e6ce757e722e95763a9dbc6f90211d5/postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/NumericSpec.scala") @Test fun `when processing numeric columns should support first update of num column with integer`() { - withHandler { handler -> executeDdl(handler, "CREATE TEMP TABLE numeric_test (id BIGSERIAL, numcol NUMERIC)") @@ -45,7 +43,6 @@ class NumericSpec : DatabaseTestHelper() { @Test fun `when processing numeric columns should support using first update with queries instead of prepared statements`() { - withHandler { handler -> executeDdl(handler, "CREATE TEMP TABLE numeric_test (id BIGSERIAL, numcol NUMERIC)") diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLConnectionSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLConnectionSpec.kt index 13c0e78af..a181f2e94 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLConnectionSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLConnectionSpec.kt @@ -128,7 +128,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `connect should return with timeout exception after create timeout`() { - class PostgreSQLSlowConnectionDelegate( private val delegate: PostgreSQLConnectionDelegate, private val onReadyForQuerySlowdownInMillis: Int @@ -157,7 +156,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should connect to the database`() { - withHandler { handler -> assertThat(handler.isReadyForQuery()).isTrue() } @@ -165,7 +163,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should create a table in the database`() { - withHandler { handler -> assertThat(executeDdl(handler, this.create)).isEqualTo(0) } @@ -173,7 +170,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should insert a row in the database`() { - withHandler { handler -> executeDdl(handler, this.create) assertThat(executeDdl(handler, this.insert, 1)).isEqualTo(1) @@ -182,7 +178,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should select rows in the database`() { - withHandler { handler -> executeDdl(handler, this.create) executeDdl(handler, this.insert, 1) @@ -208,7 +203,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should select rows that has duplicate column names`() { - withHandler { handler -> val result = executeQuery(handler, "SELECT 1 COL, 2 COL") @@ -221,7 +215,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should execute a prepared statement`() { - withHandler { handler -> executeDdl(handler, this.preparedStatementCreate) executeDdl(handler, this.preparedStatementInsert, 1) @@ -236,7 +229,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should execute a prepared statement , parameters`() { - withHandler { handler -> executeDdl(handler, this.preparedStatementCreate) executeDdl(handler, this.preparedStatementInsert, 1) @@ -261,7 +253,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should transaction and flatmap example`() { - val handler: Connection = PostgreSQLConnection(defaultConfiguration) val result: CompletableFuture = handler.connect() .mapAsync(ExecutorServiceUtils.CommonPool) { handler } @@ -278,7 +269,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should use RETURNING in an insert statement`() { - withHandler { connection -> executeDdl(connection, this.preparedStatementCreate) val result = executeQuery(connection, this.preparedStatementInsertReturning) @@ -288,7 +278,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should execute a prepared statement , limit`() { - withHandler { handler -> executeDdl(handler, this.preparedStatementCreate) executeDdl(handler, this.preparedStatementInsert, 1) @@ -304,10 +293,8 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should execute an empty query`() { - withHandler { handler -> verifyException(QueryMustNotBeNullOrEmptyException::class.java) { - assertThat(executeQuery(handler, "").rows).isNull() } } @@ -315,7 +302,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should execute an whitespace query`() { - withHandler { handler -> verifyException(ExecutionException::class.java, QueryMustNotBeNullOrEmptyException::class.java) { assertThat(executeQuery(handler, " ").rows).isNull() @@ -335,7 +321,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should load data from a bytea column`() { - val create = """create temp table file_samples ( id bigserial not null, content bytea not null, @@ -384,7 +369,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should insert a LocalDateTime`() { - withHandler { handler -> executePreparedStatement(handler, "CREATE TEMP TABLE test(t TIMESTAMP)") val date1 = LocalDateTime.now() @@ -397,7 +381,6 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { @Test fun `handler should insert ,out return after select`() { - withHandler { handler -> executeDdl(handler, this.preparedStatementCreate) executeDdl(handler, this.preparedStatementInsert, 1) @@ -419,7 +402,7 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { applicationName = "jasync_test" ) withHandler(configuration) { - handler -> + handler -> val result = executeQuery(handler, "SELECT application_name FROM pg_stat_activity WHERE pid = pg_backend_pid()") val name = result.rows[0].getString(0) assertThat(name).isEqualTo("jasync_test") @@ -440,7 +423,7 @@ class PostgreSQLConnectionSpec : DatabaseTestHelper() { interceptors = listOf(Supplier { interceptor }, mdcInterceptor) ) withHandler(configuration) { - handler -> + handler -> handler.sendQuery("SELECT application_name FROM pg_stat_activity WHERE pid = pg_backend_pid()") .map { assertThat(MDC.get("a")).isEqualTo("b") } .get(5, TimeUnit.SECONDS) diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLPoolConfigurationSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLPoolConfigurationSpec.kt index 2e87c3694..fe9cb6171 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLPoolConfigurationSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PostgreSQLPoolConfigurationSpec.kt @@ -28,7 +28,6 @@ class PostgreSQLPoolConfigurationSpec : DatabaseTestHelper() { @Test fun `handler should create a table in the database with connection pool`() { - withPoolConfigurationConnectionConnection { handler -> assertThat(executeDdl(handler, this.create)).isEqualTo(0) } @@ -54,7 +53,6 @@ class PostgreSQLPoolConfigurationSpec : DatabaseTestHelper() { @Test fun `handler should create a table in the database with connection pool builder`() { - withPoolConfigurationConnectionBuilderConnection { handler -> assertThat(executeDdl(handler, this.create)).isEqualTo(0) } @@ -78,7 +76,6 @@ class PostgreSQLPoolConfigurationSpec : DatabaseTestHelper() { @Test fun `handler should create a table in the database with connection pool parsed from url`() { - withPoolUrlConfigurationConnection { handler -> assertThat(executeDdl(handler, this.create)).isEqualTo(0) } diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PreparedStatementSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PreparedStatementSpec.kt index 966074a85..97339a079 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PreparedStatementSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/PreparedStatementSpec.kt @@ -66,7 +66,6 @@ class PreparedStatementSpec : DatabaseTestHelper() { @Test fun `prepared statements should execute a prepared statement without any parameters multiple times`() { - withHandler { handler -> executeDdl(handler, this.messagesCreate) executePreparedStatement(handler, "UPDATE messages SET content = content") @@ -76,7 +75,6 @@ class PreparedStatementSpec : DatabaseTestHelper() { @Test fun `prepared statements should raise an exception if the parameter count is different from the given parameters count`() { - withHandler { handler -> executeDdl(handler, this.messagesCreate) verifyException(InsufficientParametersException::class.java) { @@ -87,7 +85,6 @@ class PreparedStatementSpec : DatabaseTestHelper() { @Test fun `prepared statements should run two different prepared statements in sequence and get the right values`() { - val create = """CREATE TEMP TABLE other_messages ( id bigserial NOT NULL, @@ -212,7 +209,6 @@ class PreparedStatementSpec : DatabaseTestHelper() { @Test fun `prepared statements should support handling of enum types`() { - withHandler { handler -> val create = """CREATE TEMP TABLE messages |( @@ -237,7 +233,6 @@ class PreparedStatementSpec : DatabaseTestHelper() { @Test fun `prepared statements should support handling JSON type`() { - withHandler { handler -> val create = """create temp table people |( diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/TimeAndDateSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/TimeAndDateSpec.kt index 9d37e81a2..ea8d4f260 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/TimeAndDateSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/TimeAndDateSpec.kt @@ -20,7 +20,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Test fun `when processing times and dates should support a time object`() { - withHandler { handler -> val create = """CREATE TEMP TABLE messages ( @@ -44,7 +43,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Test fun `when processing times and dates should support a time object, microseconds`() { - withHandler { handler -> val create = """CREATE TEMP TABLE messages ( @@ -74,7 +72,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Ignore("need to find a way to implement this") @Test fun `when processing times and dates should support a time with timezone object`() { - withHandler { handler -> val create = """CREATE TEMP TABLE messages ( @@ -123,7 +120,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Test fun `when processing times and dates should support timestamp with timezone and microseconds`() { - (1 until 6).forEach { index -> withHandler { handler -> @@ -183,7 +179,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Test fun `when processing times and dates should handle sending a time with timezone and return a LocalDateTime for a timestamp without timezone column`() { - withHandler { conn -> val date = OffsetDateTime.ofInstant(Instant.ofEpochMilli(2190319), ZoneOffset.UTC) @@ -197,7 +192,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Test fun `when processing times and dates should supports sending a local date and later a date time object for the same field`() { - withHandler { conn -> val date = OffsetDateTime.of(2016, 3, 5, 0, 0, 0, 0, ZoneOffset.UTC) @@ -214,7 +208,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Test fun `when processing times and dates should handle sending a LocalDateTime and return a LocalDateTime for a timestamp without timezone column`() { - withHandler { conn -> val date1 = LocalDateTime.ofInstant(Instant.ofEpochMilli(2190319), ZoneOffset.UTC) @@ -229,7 +222,6 @@ class TimeAndDateSpec : DatabaseTestHelper() { @Test fun `when processing times and dates should handle sending a date with timezone and retrieving the date , the same time zone`() { - withHandler { conn -> val date1 = OffsetDateTime.ofInstant(Instant.ofEpochMilli(2190319), ZoneOffset.UTC) diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/ActorAsyncObjectPoolSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/ActorAsyncObjectPoolSpec.kt index 92b62fd46..b0d8abe3e 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/ActorAsyncObjectPoolSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/ActorAsyncObjectPoolSpec.kt @@ -24,7 +24,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should give me a valid object when I ask for one`() { - withPool { pool -> val connection = get(pool) val result = executeTest(connection) @@ -35,7 +34,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should enqueue an action if the pool is full`() { - withPool(1, 3) { pool -> val connection = get(pool) @@ -76,7 +74,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should exhaust the pool`() { - withPool(1, 1) { pool -> (1..2).forEach { _ -> pool.take() @@ -89,7 +86,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should it should remove idle connections once the time limit has been reached`() { - withPool(validationInterval = 1000) { pool -> val connections = (1..5).map { _ -> val connection = get(pool) @@ -109,7 +105,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should it should remove aged out connections once the time limit has been reached`() { - withPool(validationInterval = 1000, maxTtl = 1000) { pool -> val connections = (1..5).map { _ -> val connection = get(pool) @@ -128,7 +123,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should it should validate returned connections before sending them back to the pool`() { - withPool { pool -> val connection = get(pool) awaitFuture(connection.disconnect()) @@ -146,7 +140,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should it should not accept returned connections that aren't ready for query`() { - withPool { pool -> val connection = get(pool) connection.sendPreparedStatement("SELECT pg_sleep(3)") @@ -167,7 +160,6 @@ class ActorAsyncObjectPoolSpec : DatabaseTestHelper() { maxTtl: Long = -1, fn: (ActorBasedObjectPool) -> T ): T { - val poolConfiguration = PoolConfiguration( maxIdle = maxTtl, maxObjects = maxObjects, diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/NextGenConnectionPoolSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/NextGenConnectionPoolSpec.kt index aa04c0486..1effcf5a4 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/NextGenConnectionPoolSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/NextGenConnectionPoolSpec.kt @@ -17,7 +17,6 @@ class NextGenConnectionPoolSpec : DatabaseTestHelper() { @Test fun `pool should give you a connection when sending statements`() { - withPool { pool -> assertThat(executeQuery(pool, "SELECT 8").rows.get(0)(0)).isEqualTo(8) Thread.sleep(1000) @@ -43,7 +42,6 @@ class NextGenConnectionPoolSpec : DatabaseTestHelper() { @Test fun `pool should runs commands for a transaction in a single connection`() { - val id = UUID.randomUUID().toString() withPool { pool -> diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/PoolHelper.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/PoolHelper.kt index 2db11a890..e27bee9fe 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/PoolHelper.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/PoolHelper.kt @@ -31,7 +31,6 @@ fun withPool( validationInterval: Long = 3000, fn: (ConnectionPool) -> T ): T { - val poolConfiguration = ConnectionPoolConfiguration( host = ContainerHelper.defaultConfiguration.host, port = ContainerHelper.defaultConfiguration.port, diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/SingleThreadedAsyncObjectPoolSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/SingleThreadedAsyncObjectPoolSpec.kt index d9827bbd1..b51b016a9 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/SingleThreadedAsyncObjectPoolSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/integration/pool/SingleThreadedAsyncObjectPoolSpec.kt @@ -22,7 +22,6 @@ class SingleThreadedAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should give me a valid object when I ask for one`() { - withPool { pool -> val connection = get(pool) val result = executeTest(connection) @@ -33,7 +32,6 @@ class SingleThreadedAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should enqueue an action if the pool is full`() { - withPool(1, 3) { pool -> val connection = get(pool) @@ -77,7 +75,6 @@ class SingleThreadedAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should exhaust the pool`() { - withPool(1, 1) { pool -> (1..2).forEach { _ -> pool.take() @@ -90,7 +87,6 @@ class SingleThreadedAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should it should remove idle connections once the time limit has been reached`() { - withPool(validationInterval = 1000) { pool -> val connections = (1..5).map { _ -> val connection = get(pool) @@ -110,7 +106,6 @@ class SingleThreadedAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should it should validate returned connections before sending them back to the pool`() { - withPool { pool -> val connection = get(pool) awaitFuture(connection.disconnect()) @@ -128,7 +123,6 @@ class SingleThreadedAsyncObjectPoolSpec : DatabaseTestHelper() { @Test fun `pool should it should not accept returned connections that aren't ready for query`() { - withPool { pool -> val connection = get(pool) connection.sendPreparedStatement("SELECT pg_sleep(3)") diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/MessageDecoderSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/MessageDecoderSpec.kt index 42133ce6a..6c803b58f 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/MessageDecoderSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/MessageDecoderSpec.kt @@ -19,7 +19,6 @@ class MessageDecoderSpec { @Test fun `message decoder should not try to decode if there is not enough data available`() { - val buffer = Unpooled.buffer() buffer.writeByte('R'.toInt()) @@ -33,7 +32,6 @@ class MessageDecoderSpec { @Test fun `should not try to decode if there is a type and length but it is not long enough`() { - val buffer = Unpooled.buffer() buffer.writeByte('R'.toInt()) @@ -47,7 +45,6 @@ class MessageDecoderSpec { @Test fun `should correctly decode a message`() { - val buffer = Unpooled.buffer() val text = "This is an error message" val textBytes = text.toByteArray(CharsetUtil.UTF_8) @@ -77,7 +74,6 @@ class MessageDecoderSpec { @Test(expected = MessageTooLongException::class) fun `should raise an exception if the length is too big`() { - val buffer = Unpooled.buffer() buffer.writeByte(ServerMessage.Close) buffer.writeInt(MessageDecoder_DefaultMaximumSize + 10) diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/PostgreSQLColumnEncoderRegistrySpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/PostgreSQLColumnEncoderRegistrySpec.kt index cb229f122..c43a8230e 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/PostgreSQLColumnEncoderRegistrySpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/PostgreSQLColumnEncoderRegistrySpec.kt @@ -10,7 +10,6 @@ class PostgreSQLColumnEncoderRegistrySpec { @Test fun `column encoder registry should encode Some(value) like value`() { - val actual = encoder.encode(1L) val expected = encoder.encode(1L) diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ArrayDecoderSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ArrayDecoderSpec.kt index 3757cecee..e885fea9b 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ArrayDecoderSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ArrayDecoderSpec.kt @@ -18,7 +18,6 @@ class ArrayDecoderSpec { @Test fun `encoder decoder should parse an array of numbers`() { - assertThat(execute("{1,2,3}")).isEqualTo(listOf(1, 2, 3)) } diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ByteArrayDecoderSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ByteArrayDecoderSpec.kt index 18f43ddfe..b820145c0 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ByteArrayDecoderSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/column/ByteArrayDecoderSpec.kt @@ -41,7 +41,6 @@ class ByteArrayDecoderSpec { @Test fun `decoder should parse escape data`() { - assertThat(ByteArrayEncoderDecoder.decode(escapeTestData)).isEqualTo(originalData) } diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/encoders/ExecutePreparedStatementEncoderSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/encoders/ExecutePreparedStatementEncoderSpec.kt index 9a8a2d279..67cf8725e 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/encoders/ExecutePreparedStatementEncoderSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/encoders/ExecutePreparedStatementEncoderSpec.kt @@ -200,7 +200,6 @@ class ExecutePreparedStatementEncoderSpec { @Test fun `encoder should correctly handle the case where an encoder returns null`() { - val uuid = UUID.fromString("3edfe88f-f0d0-46bc-8580-053b9e8af6c5") val message = PreparedStatementExecuteMessage(uuid, "select * from users", listOf(null), registry) diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserESpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserESpec.kt index 06becd6ba..85e6456db 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserESpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserESpec.kt @@ -12,7 +12,6 @@ class ParserESpec { @Test fun `ErrorParser should correctly parse an error message`() { - val content = "this is my error message" val error = content.toByteArray(CharsetUtil.UTF_8) val buffer = Unpooled.buffer() diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserKSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserKSpec.kt index d6b6ff7cc..d60801685 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserKSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserKSpec.kt @@ -13,7 +13,6 @@ class ParserKSpec { @Test fun `parserk should correctly parse the message`() { - val buffer = Unpooled.buffer() buffer.writeInt(10) buffer.writeInt(20) diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserSSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserSSpec.kt index 33774a8c0..b95e9b4b6 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserSSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/parsers/ParserSSpec.kt @@ -15,7 +15,6 @@ class ParserSSpec { @Test fun `ParameterStatusParser should correctly parse a config pair`() { - val key = "application-name" val value = "my-cool-application" diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/ArrayStreamingParserSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/ArrayStreamingParserSpec.kt index f312ef419..d95a96cfe 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/ArrayStreamingParserSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/ArrayStreamingParserSpec.kt @@ -11,7 +11,6 @@ class ArrayStreamingParserSpec { @Test fun `parser should generate the events correctly`() { - val content = "{{1,2,3},{4,5,6}}" val delegate = LoggingDelegate() diff --git a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/PasswordHelperSpec.kt b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/PasswordHelperSpec.kt index 1ab8b536e..05d86e897 100644 --- a/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/PasswordHelperSpec.kt +++ b/postgresql-async/src/test/java/com/github/aysnc/sql/db/postgresql/util/PasswordHelperSpec.kt @@ -52,7 +52,6 @@ class PasswordHelperSpec { @Test fun `helper should generate the same value as the PostgreSQL code`() { - val username = "jasync" val password = "example" diff --git a/r2dbc-mysql/build.gradle.kts b/r2dbc-mysql/build.gradle.kts index edd62ff2b..2ee44e9e9 100644 --- a/r2dbc-mysql/build.gradle.kts +++ b/r2dbc-mysql/build.gradle.kts @@ -15,26 +15,27 @@ val LOGBACK_VERSION: String by project val TEST_CONTAINERS_VERSION: String by project val MYSQL_CONNECTOR_VERSION: String by project val AWAITILITY_VERSION: String by project +val REACTOR_KOTLIN_EXTENSION: String by project repositories { mavenCentral() } dependencies { - compile(project(":db-async-common")) - compile(project(":pool-async")) - compile(project(":mysql-async")) - compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") - compile("org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION") - compile("io.r2dbc:r2dbc-spi:$R2DBC_SPI_VERSION") + api(project(":db-async-common")) + api(project(":pool-async")) + api(project(":mysql-async")) + api("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$KOTLIN_VERSION") + api("org.jetbrains.kotlin:kotlin-reflect:$KOTLIN_VERSION") + api("io.r2dbc:r2dbc-spi:$R2DBC_SPI_VERSION") implementation("io.projectreactor:reactor-core:$REACTOR_CORE_VERSION") - implementation("io.projectreactor.kotlin:reactor-kotlin-extensions:1.1.7") - compile("org.slf4j:slf4j-api:$SL4J_VERSION") - compile("joda-time:joda-time:$JODA_VERSION") - compile("org.joda:joda-convert:$JODA_CONVERT_VERSION") - compile("io.netty:netty-transport:$NETTY_VERSION") - compile("io.netty:netty-handler:$NETTY_VERSION") - compile("io.github.microutils:kotlin-logging:$KOTLIN_LOGGING_VERSION") + implementation("io.projectreactor.kotlin:reactor-kotlin-extensions:$REACTOR_KOTLIN_EXTENSION") + api("org.slf4j:slf4j-api:$SL4J_VERSION") + api("joda-time:joda-time:$JODA_VERSION") + api("org.joda:joda-convert:$JODA_CONVERT_VERSION") + api("io.netty:netty-transport:$NETTY_VERSION") + api("io.netty:netty-handler:$NETTY_VERSION") + api("io.github.oshai:kotlin-logging-jvm:$KOTLIN_LOGGING_VERSION") testImplementation("org.springframework.data:spring-data-r2dbc:1.5.6") testImplementation("io.r2dbc:r2dbc-pool:1.0.0.RELEASE") testImplementation("junit:junit:$JUNIT_VERSION") diff --git a/r2dbc-mysql/src/main/java/JasyncMetadata.kt b/r2dbc-mysql/src/main/java/JasyncMetadata.kt index e941474bd..3f6e5b25c 100644 --- a/r2dbc-mysql/src/main/java/JasyncMetadata.kt +++ b/r2dbc-mysql/src/main/java/JasyncMetadata.kt @@ -15,7 +15,8 @@ class JasyncMetadata(rows: ResultSet) : RowMetadata { throw ArrayIndexOutOfBoundsException( String .format( - "Column index %d is larger than the number of columns %d", index, + "Column index %d is larger than the number of columns %d", + index, columnNames .size ) diff --git a/r2dbc-mysql/src/main/java/JasyncStatement.kt b/r2dbc-mysql/src/main/java/JasyncStatement.kt index fa014789d..3e4074334 100644 --- a/r2dbc-mysql/src/main/java/JasyncStatement.kt +++ b/r2dbc-mysql/src/main/java/JasyncStatement.kt @@ -5,6 +5,7 @@ import com.github.jasync.sql.db.exceptions.InsufficientParametersException import com.github.jasync.sql.db.mysql.MySQLQueryResult import com.github.jasync.sql.db.mysql.exceptions.MySQLException import com.github.jasync.sql.db.mysql.exceptions.MysqlErrors +import io.github.oshai.kotlinlogging.KotlinLogging import io.r2dbc.spi.Parameter import io.r2dbc.spi.R2dbcBadGrammarException import io.r2dbc.spi.R2dbcDataIntegrityViolationException @@ -15,7 +16,6 @@ import io.r2dbc.spi.R2dbcTimeoutException import io.r2dbc.spi.R2dbcTransientResourceException import io.r2dbc.spi.Result import io.r2dbc.spi.Statement -import mu.KotlinLogging import org.reactivestreams.Publisher import reactor.core.publisher.Mono import reactor.kotlin.core.publisher.onErrorMap @@ -165,7 +165,7 @@ internal class JasyncStatement(private val clientSupplier: Supplier R2dbcDataIntegrityViolationException( errorMessage.errorMessage, errorMessage.sqlState, @@ -180,7 +180,7 @@ internal class JasyncStatement(private val clientSupplier: Supplier R2dbcBadGrammarException( errorMessage.errorMessage, errorMessage.sqlState, @@ -190,18 +190,27 @@ internal class JasyncStatement(private val clientSupplier: Supplier R2dbcTimeoutException( - errorMessage.errorMessage, errorMessage.sqlState, errorMessage.errorCode, throwable + 3024 -> R2dbcTimeoutException( + errorMessage.errorMessage, + errorMessage.sqlState, + errorMessage.errorCode, + throwable ) MysqlErrors.ER_XA_RBROLLBACK, MysqlErrors.ER_XA_RBTIMEOUT -> R2dbcRollbackException( - errorMessage.errorMessage, errorMessage.sqlState, errorMessage.errorCode, throwable + errorMessage.errorMessage, + errorMessage.sqlState, + errorMessage.errorCode, + throwable ) MysqlErrors.ER_NET_READ_INTERRUPTED, MysqlErrors.ER_NET_WRITE_INTERRUPTED, MysqlErrors.ER_LOCK_DEADLOCK, - MysqlErrors.ER_QUERY_INTERRUPTED, -> R2dbcTransientResourceException( - errorMessage.errorMessage, errorMessage.sqlState, errorMessage.errorCode, throwable + MysqlErrors.ER_QUERY_INTERRUPTED -> R2dbcTransientResourceException( + errorMessage.errorMessage, + errorMessage.sqlState, + errorMessage.errorCode, + throwable ) else -> when (errorMessage.sqlState.take(2)) { "0A", "22", "26", "2F", "20", "42", "XA" -> R2dbcBadGrammarException( diff --git a/r2dbc-mysql/src/main/java/MysqlConnectionFactoryProvider.kt b/r2dbc-mysql/src/main/java/MysqlConnectionFactoryProvider.kt index b4b903cc8..38ea337c3 100644 --- a/r2dbc-mysql/src/main/java/MysqlConnectionFactoryProvider.kt +++ b/r2dbc-mysql/src/main/java/MysqlConnectionFactoryProvider.kt @@ -3,6 +3,7 @@ package com.github.jasync.r2dbc.mysql import com.github.jasync.sql.db.Configuration import com.github.jasync.sql.db.mysql.MySQLConnection.Companion.CLIENT_FOUND_ROWS_PROP_NAME import com.github.jasync.sql.db.mysql.pool.MySQLConnectionFactory +import io.github.oshai.kotlinlogging.KotlinLogging import io.r2dbc.spi.ConnectionFactoryOptions import io.r2dbc.spi.ConnectionFactoryOptions.CONNECT_TIMEOUT import io.r2dbc.spi.ConnectionFactoryOptions.DATABASE @@ -14,7 +15,6 @@ import io.r2dbc.spi.ConnectionFactoryOptions.STATEMENT_TIMEOUT import io.r2dbc.spi.ConnectionFactoryOptions.USER import io.r2dbc.spi.ConnectionFactoryProvider import io.r2dbc.spi.Option -import mu.KotlinLogging import java.nio.file.Paths import java.time.Duration import kotlin.properties.ReadWriteProperty diff --git a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/MysqlSSLConfigurationFactoryTest.kt b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/MysqlSSLConfigurationFactoryTest.kt index 52d9cb747..af5a2b980 100644 --- a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/MysqlSSLConfigurationFactoryTest.kt +++ b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/MysqlSSLConfigurationFactoryTest.kt @@ -95,7 +95,7 @@ internal class MysqlSSLConfigurationFactoryTest( .build(), expected = SSLConfiguration(mode = VerifyFull), message = "sslMode should be 'verify_identity'" - ), + ) ) private fun createTestParams( diff --git a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/JasyncR2dbcIntegTest.kt b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/JasyncR2dbcIntegTest.kt index d591377aa..8a4dc7831 100644 --- a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/JasyncR2dbcIntegTest.kt +++ b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/JasyncR2dbcIntegTest.kt @@ -4,12 +4,12 @@ import com.github.jasync.r2dbc.mysql.JasyncConnectionFactory import com.github.jasync.sql.db.mysql.MySQLConnection import com.github.jasync.sql.db.mysql.pool.MySQLConnectionFactory import com.github.jasync.sql.db.util.FP +import io.github.oshai.kotlinlogging.KotlinLogging import io.mockk.mockk import io.r2dbc.pool.ConnectionPoolConfiguration import io.r2dbc.spi.Parameter import io.r2dbc.spi.Result import io.r2dbc.spi.Type -import mu.KotlinLogging import org.assertj.core.api.Assertions.assertThat import org.awaitility.kotlin.await import org.hamcrest.core.IsEqual @@ -188,7 +188,7 @@ class JasyncR2dbcIntegTest : R2dbcConnectionHelper() { "name", "id", "title", - "user_id", + "user_id" ) ) } diff --git a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcConnectionHelper.kt b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcConnectionHelper.kt index 919edfdc3..3d2ae7905 100644 --- a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcConnectionHelper.kt +++ b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcConnectionHelper.kt @@ -107,7 +107,6 @@ open class R2dbcConnectionHelper : R2dbcContainerHelper() { } fun withConfigurablePool(configuration: Configuration, f: (ConnectionPool) -> T): T { - val poolConfiguration = ConnectionPoolConfiguration( host = configuration.host, port = configuration.port, diff --git a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcTransactionIntegrationTest.kt b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcTransactionIntegrationTest.kt index 62c4d81f1..08b19d898 100644 --- a/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcTransactionIntegrationTest.kt +++ b/r2dbc-mysql/src/test/java/com/github/jasync/r2dbc/mysql/integ/R2dbcTransactionIntegrationTest.kt @@ -179,7 +179,9 @@ class R2dbcTransactionIntegrationTest : R2dbcConnectionHelper() { } return if (TransactionDefinition.LOCK_WAIT_TIMEOUT == option && !this.lockWaitTimeout.isZero) { this.lockWaitTimeout - } else null + } else { + null + } } } } diff --git a/samples/ktor/build.gradle b/samples/ktor/build.gradle index 3fbbe8587..2e0148f97 100644 --- a/samples/ktor/build.gradle +++ b/samples/ktor/build.gradle @@ -36,7 +36,7 @@ dependencies { implementation "io.ktor:ktor-server-core:$ktor_version" implementation "io.ktor:ktor-server-host-common:$ktor_version" implementation "io.ktor:ktor-gson:$ktor_version" - implementation "io.github.microutils:kotlin-logging:1.6.10" + implementation "io.github.oshai:kotlin-logging-jvm:1.6.10" implementation 'com.github.jasync-sql:jasync-mysql:0.9.23' testImplementation "io.ktor:ktor-server-tests:$ktor_version" testImplementation "io.ktor:ktor-server-core:$ktor_version" diff --git a/samples/ktor/src/application.kt b/samples/ktor/src/application.kt index 3a89b97ab..fc0b4ba44 100644 --- a/samples/ktor/src/application.kt +++ b/samples/ktor/src/application.kt @@ -15,7 +15,7 @@ import io.ktor.server.engine.embeddedServer import io.ktor.server.netty.Netty import io.ktor.util.pipeline.PipelineContext import kotlinx.coroutines.future.await -import mu.KotlinLogging +import io.github.oshai.kotlinlogging.KotlinLogging import java.util.concurrent.TimeUnit