Lettuce: properly close connection instead of letting it being GCed
MODIFY
dd-java-agent/instrumentation/lettuce-5/src/test/groovy/LettuceAsyncClientTest.groovy
dd-java-agent/instrumentation/lettuce-5/src/test/groovy/LettuceAsyncClientTest.groovy
@@ -54,6 +54,8 @@ class LettuceAsyncClientTest extends AgentTestRunner {
@Shared
RedisClient redisClient = RedisClient.create(EMBEDDED_DB_URI)
+ @Shared
+ StatefulConnection connection
@Shared
RedisAsyncCommands<String, ?> asyncCommands = null
@@ -67,11 +69,14 @@ class LettuceAsyncClientTest extends AgentTestRunner {
def setupSpec() {
println "Using redis: $redisServer.args"
redisServer.start()
- StatefulConnection connection = redisClient.connect()
+ connection = redisClient.connect()
asyncCommands = connection.async()
+ TEST_WRITER.waitForTraces(1)
+ TEST_WRITER.clear()
}
def cleanupSpec() {
+ connection.close()
redisServer.stop()
}

MODIFY
dd-java-agent/instrumentation/lettuce-5/src/test/groovy/LettuceReactiveClientTest.groovy
dd-java-agent/instrumentation/lettuce-5/src/test/groovy/LettuceReactiveClientTest.groovy
@@ -37,17 +37,22 @@ class LettuceReactiveClientTest extends AgentTestRunner {
@Shared
RedisClient redisClient = RedisClient.create(EMBEDDED_DB_URI)
+ @Shared
+ StatefulConnection connection
@Shared
RedisReactiveCommands<String, ?> reactiveCommands = null
def setupSpec() {
println "Using redis: $redisServer.args"
redisServer.start()
- StatefulConnection connection = redisClient.connect()
+ connection = redisClient.connect()
reactiveCommands = connection.reactive()
+ TEST_WRITER.waitForTraces(1)
+ TEST_WRITER.clear()
}
def cleanupSpec() {
+ connection.close()
redisServer.stop()
}

MODIFY
dd-java-agent/instrumentation/lettuce-5/src/test/groovy/LettuceSyncClientTest.groovy
dd-java-agent/instrumentation/lettuce-5/src/test/groovy/LettuceSyncClientTest.groovy
@@ -42,6 +42,8 @@ class LettuceSyncClientTest extends AgentTestRunner {
@Shared
RedisClient redisClient = RedisClient.create(EMBEDDED_DB_URI)
+ @Shared
+ StatefulConnection connection
@Shared
RedisCommands<String, ?> syncCommands = null
@@ -54,13 +56,14 @@ class LettuceSyncClientTest extends AgentTestRunner {
def setupSpec() {
redisServer.start()
- StatefulConnection connection = redisClient.connect()
+ connection = redisClient.connect()
syncCommands = connection.sync()
TEST_WRITER.waitForTraces(1)
TEST_WRITER.clear()
}
def cleanupSpec() {
+ connection.close()
redisServer.stop()
}

Lettuce: properly close connection instead of letting it being GCed