Lettuce: properly close connection instead of letting it being GCed

This commit is contained in:
Nikolay Martynov 2018-06-19 15:38:08 -04:00
parent b0c2ab9b68
commit 21d58768cb
3 changed files with 16 additions and 3 deletions

View File

@ -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()
}

View File

@ -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()
}

View File

@ -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()
}