Sitelet https://github.com/jasync-sql/jasync-sql/pull/438/files
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ abstract class ConnectionFactory<T : ConcreteConnection> : ObjectFactory<T> {
try {
item.disconnect()
} catch (e: Exception) {
logger.error("Failed to close the connection", e)
logger.error(e) { "Failed to close the connection" }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ abstract class AbstractURIParser {
return try {
parseOrDie(url, charset)
} catch (e: Exception) {
logger.warn("Connection url '$url' could not be parsed.", e)
logger.warn(e) { "Connection url '$url' could not be parsed." }
// Fallback to default to maintain current behavior
DEFAULT
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import io.netty.buffer.ByteBuf
object PrintUtils {

fun printArray(name: String, buffer: ByteBuf) {
if (logger.isTraceEnabled) {
if (logger.isTraceEnabled()) {
buffer.markReaderIndex()
val bytes = ByteArray(buffer.readableBytes())
buffer.readBytes(bytes)
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
KOTLIN_VERSION=1.8.21
KOTLIN_VERSION=2.0.21
KTLINT_VERSION=11.3.1
JACOCO_VERSION=0.8.8
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=5.0.0
KOTLIN_LOGGING_VERSION=8.0.4
SCRAM_CLIENT_VERSION=2.1
R2DBC_SPI_VERSION=1.0.0.RELEASE
REACTOR_CORE_VERSION=3.5.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ class MySQLConnection @JvmOverloads constructor(
reportErrorAfterChannelClosed = true
}
}
logger.error("$connectionId Transport failure ", exception)
logger.error(exception) { "$connectionId Transport failure " }
setException(exception)
}

override fun onError(message: ErrorMessage) {
logger.error("$connectionId Received an error message -> {}", message)
logger.error { "$connectionId Received an error message -> $message" }
val exception = MySQLException(message)
this.setException(exception)
}
Expand All @@ -221,7 +221,7 @@ class MySQLConnection @JvmOverloads constructor(
override fun onOk(message: OkMessage) {
this.serverStatus = message.statusFlags
if (!this.connectionPromise.isCompleted) {
logger.debug("$connectionId Connected to database")
logger.debug { "$connectionId Connected to database" }
this.connectionPromise.success(this)
} else {
if (this.isQuerying()) {
Expand All @@ -248,7 +248,7 @@ class MySQLConnection @JvmOverloads constructor(
)
}
} else {
logger.warn("$connectionId Received OK when not querying or connecting, not sure what this is: $message")
logger.warn { "$connectionId Received OK when not querying or connecting, not sure what this is: $message" }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class MySQLOneToOneEncoder(charset: Charset, charsetMapper: CharsetMapper) :

sequence += 1

if (logger.isTraceEnabled) {
logger.trace("Writing message ${message::class.java.simpleName} - \n${BufferDumper.dumpAsHex(result)}")
if (logger.isTraceEnabled()) {
logger.trace { "Writing message ${message::class.java.simpleName} - \n${BufferDumper.dumpAsHex(result)}" }
}

out.add(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HandshakeV10Decoder : MessageDecoder {
// next 10 bytes are reserved (all <00>)
buffer.readerIndex(buffer.readerIndex() + Padding)

logger.debug("Auth plugin data length was $authPluginDataLength")
logger.debug { "Auth plugin data length was $authPluginDataLength" }

if ((serverCapabilityFlags and CLIENT_SECURE_CONNECTION.value) != 0) {
val complement = if (authPluginDataLength > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object ConcurrentlyRunTest : ConnectionHelper(), Runnable {

@JvmStatic
fun main(args: Array<String>) {
logger.info("Starting executing code")
logger.info { "Starting executing code" }

val threads = 1.until(10).map { Thread(this) }

Expand All @@ -23,7 +23,7 @@ object ConcurrentlyRunTest : ConnectionHelper(), Runnable {
Thread.sleep(5000)
}

logger.info("Finished executing code, failed execution ${ConcurrentlyRunTest.failures.get()} times")
logger.info { "Finished executing code, failed execution ${ConcurrentlyRunTest.failures.get()} times" }
}

private val counter = AtomicInteger()
Expand All @@ -35,7 +35,7 @@ object ConcurrentlyRunTest : ConnectionHelper(), Runnable {

private fun execute(count: Int) {
try {
logger.info("====> run $count")
logger.info { "====> run $count" }
val create = """CREATE TEMPORARY TABLE posts (
| id INT NOT NULL AUTO_INCREMENT,
| some_text TEXT not null,
Expand All @@ -61,11 +61,11 @@ object ConcurrentlyRunTest : ConnectionHelper(), Runnable {
assert(queryRow["some_text"] == "this is some text here")
assert(queryRow["some_date"] == null)

logger.info("====> run $count end")
logger.info { "====> run $count end" }
}
} catch (e: Exception) {
failures.incrementAndGet()
logger.error("Failed to execute on run $count - ${e.message}", e)
logger.error(e) { "Failed to execute on run $count - ${e.message}" }
}
}
}
10 changes: 5 additions & 5 deletions postgis-jasync/src/test/java/ContainerHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object ContainerHelper {
defaultConfiguration = Configuration(username, host, port, password, database)
try {
PostgreSQLConnection(defaultConfiguration).connect().get(1, TimeUnit.SECONDS)
logger.info("Using local postgresql instance $defaultConfiguration")
logger.info { "Using local postgresql instance $defaultConfiguration" }
} catch (e: Exception) {
// If local instance isn't running, start a docker postgresql on random port
if (postgresql == null) {
Expand All @@ -49,12 +49,12 @@ object ContainerHelper {
postgresql!!.getPassword(),
postgresql!!.getDatabaseName()
)
logger.info("PORT is " + defaultConfiguration.port)
logger.info("Using test container instance {}", defaultConfiguration)
logger.info { "PORT is " + defaultConfiguration.port }
logger.info { "Using test container instance $defaultConfiguration" }
} finally {
try {
val connection = PostgreSQLConnection(defaultConfiguration).connect().get(1, TimeUnit.SECONDS)
logger.info("got connection " + connection.isConnected())
logger.info { "got connection " + connection.isConnected() }
connection.sendQuery(
"""
DROP TYPE IF EXISTS example_mood; CREATE TYPE example_mood AS ENUM ('sad', 'ok', 'happy')
Expand All @@ -70,7 +70,7 @@ object ContainerHelper {
"""
).get()
} catch (e: Exception) {
logger.error(e.localizedMessage, e)
logger.error(e) { e.localizedMessage }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class PostgreSQLConnection @JvmOverloads constructor(
this.lastException = e
this.recentError = true

logger.error("Error on connection", e)
logger.error(e) { "Error on connection" }

if (!this.connectionFuture.isCompleted) {
this.connectionFuture.failed(e)
Expand All @@ -248,7 +248,7 @@ class PostgreSQLConnection @JvmOverloads constructor(
}

override fun onError(message: ErrorMessage) {
logger.error("Error , message -> {}", message)
logger.error { "Error , message -> $message" }

val error = GenericDatabaseException(message)

Expand Down Expand Up @@ -300,7 +300,7 @@ class PostgreSQLConnection @JvmOverloads constructor(
override fun onAuthenticationResponse(message: AuthenticationMessage) {
when (message) {
is AuthenticationOkMessage -> {
logger.debug("Successfully logged in to database")
logger.debug { "Successfully logged in to database" }
this.authenticated = true
}
is AuthenticationCleartextPasswordMessage -> write(this.createPasswordMessage(message))
Expand Down Expand Up @@ -374,7 +374,7 @@ class PostgreSQLConnection @JvmOverloads constructor(
}

private fun notReadyForQueryError(errorMessage: String, race: Boolean) {
logger.error(errorMessage)
logger.error { errorMessage }
throw ConnectionStillRunningQueryException(
this.id,
race
Expand Down Expand Up @@ -412,7 +412,7 @@ class PostgreSQLConnection @JvmOverloads constructor(

private fun failQueryPromise(t: Throwable) {
this.clearQueryPromise().ifPresent { promise ->
logger.error("Setting error on future {}", promise)
logger.error { "Setting error on future $promise" }
promise.failed(t)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class PostgreSQLConnectionHandler(
ServerMessage.BindComplete -> {
}
ServerMessage.Authentication -> {
logger.debug("Authentication response received $message")
logger.debug { "Authentication response received $message" }
connectionDelegate.onAuthenticationResponse(message as AuthenticationMessage)
}
ServerMessage.CommandComplete -> {
Expand All @@ -190,7 +190,7 @@ class PostgreSQLConnectionHandler(
ServerMessage.NoData -> {
}
ServerMessage.Notice -> {
logger.info("Received notice $message")
logger.info { "Received notice $message" }
}
ServerMessage.NotificationResponse -> {
connectionDelegate.onNotificationResponse(message as NotificationResponse)
Expand All @@ -214,7 +214,7 @@ class PostgreSQLConnectionHandler(
}
}
else -> {
logger.error("Unknown message type - $message")
logger.error { "Unknown message type - $message" }
val exception = IllegalArgumentException("Unknown message type - %s".format(message))
connectionDelegate.onError(exception)
}
Expand All @@ -238,7 +238,7 @@ class PostgreSQLConnectionHandler(

@Suppress("RedundantUnitReturnType")
override fun channelInactive(ctx: ChannelHandlerContext) {
logger.info("Connection disconnected - {}", ctx.channel().remoteAddress())
logger.info { "Connection disconnected - ${ctx.channel().remoteAddress()}" }
}

override fun handlerAdded(ctx: ChannelHandlerContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class CloseStatementEncoder(val charset: Charset) : Encoder, PreparedStatementEn
override fun encode(message: ClientMessage): ByteBuf {
val m = message as PreparedStatementCloseMessage

if (logger.isDebugEnabled) {
logger.debug("Closing statement ({})", m)
if (logger.isDebugEnabled()) {
logger.debug { "Closing statement ($m)" }
}

return closeAndSyncBuffer(m.statementId.toString().toByteArray(charset), PreparedStatementEncoderHelper.Statement)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface PreparedStatementEncoderHelper {

bindBuffer.writeShort(values.length)

val decodedValues = if (logger.isDebugEnabled) {
val decodedValues = if (logger.isDebugEnabled()) {
mutableListOf<String?>()
} else {
null
Expand All @@ -52,13 +52,13 @@ interface PreparedStatementEncoderHelper {
if (value == null) {
bindBuffer.writeInt(-1)

if (logger.isDebugEnabled) {
if (logger.isDebugEnabled()) {
decodedValues?.add(null)
}
} else {
val encodedValue = encoder.encode(value)

if (logger.isDebugEnabled) {
if (logger.isDebugEnabled()) {
decodedValues?.add(encodedValue)
}

Expand All @@ -72,14 +72,14 @@ interface PreparedStatementEncoderHelper {
}
}

if (logger.isDebugEnabled) {
logger.debug(
if (logger.isDebugEnabled()) {
logger.debug {
"Executing portal - statement id " +
"(${statementIdBytes.joinToString("-")}) - statement ($query) - " +
"encoded values (${decodedValues?.joinToString(", ")}) - original values (${values.joinToString(
","
)})"
)
}
}

bindBuffer.writeShort(0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ class PreparedStatementOpeningEncoder(val charset: Charset, val encoder: ColumnE

parseBuffer.writeShort(columnCount)

if (logger.isDebugEnabled) {
logger.debug(
if (logger.isDebugEnabled()) {
logger.debug {
"Opening query (${m.query}) - statement id (${statementIdBytes.joinToString("-")}) - selected types (${m.valueTypes.joinToString(
", "
)}) - values (${m.values.joinToString(", ")})"
)
}
}

for (kind in m.valueTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class QueryMessageEncoder(val charset: Charset) : Encoder {

override fun encode(message: ClientMessage): ByteBuf {
val m = message as QueryMessage
logger.debug("Executing direct query ({})", m.query)
logger.debug { "Executing direct query (${m.query})" }

val buffer = Unpooled.buffer()
buffer.writeByte(ServerMessage.Query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object ContainerHelper {
defaultConfiguration = Configuration(username, host, port, password, database)
try {
PostgreSQLConnection(defaultConfiguration).connect().get(1, TimeUnit.SECONDS)
logger.info("Using local postgresql instance $defaultConfiguration")
logger.info { "Using local postgresql instance $defaultConfiguration" }
} catch (e: Exception) {
// If local instance isn't running, start a docker postgresql on random port
if (postgresql == null) {
Expand All @@ -48,12 +48,12 @@ object ContainerHelper {
postgresql!!.getPassword(),
postgresql!!.getDatabaseName()
)
logger.info("PORT is " + defaultConfiguration.port)
logger.info("Using test container instance {}", defaultConfiguration)
logger.info { "PORT is " + defaultConfiguration.port }
logger.info { "Using test container instance $defaultConfiguration" }
} finally {
try {
val connection = PostgreSQLConnection(defaultConfiguration).connect().get(1, TimeUnit.SECONDS)
logger.info("got connection " + connection.isConnected())
logger.info { "got connection " + connection.isConnected() }
connection.sendQuery(
"""
DROP TYPE IF EXISTS example_mood; CREATE TYPE example_mood AS ENUM ('sad', 'ok', 'happy')
Expand All @@ -69,7 +69,7 @@ object ContainerHelper {
"""
).get()
} catch (e: Exception) {
logger.error(e.localizedMessage, e)
logger.error(e) { e.localizedMessage }
}
}
}
Expand Down