Resolve Redis Client Connection Issue in Integration Test

- Resolves a race condition where a client instance is closed
  before it can be used by another test
This commit is contained in:
Tapan Avasthi 2020-02-12 23:28:12 +05:30
parent 125c07509d
commit 61787725fa
3 changed files with 11 additions and 4 deletions

View File

@ -145,5 +145,10 @@ public class RedisClient {
log.error("Exception caught in flushAll", ex);
}
}
public void destroyInstance() {
jedisPool = null;
instance = null;
}
}

View File

@ -25,13 +25,14 @@ public class NaiveApproachIntegrationTest {
s.close();
redisServer = new RedisServer(port);
redisServer.start();
}
@AfterClass
public static void destroy() {
if (redisServer.isActive())
if (redisServer.isActive()) {
redisServer.stop();
redisClient.destroyInstance();
}
}
@Before

View File

@ -32,13 +32,14 @@ public class ScanStrategyIntegrationTest {
s.close();
redisServer = new RedisServer(port);
redisServer.start();
}
@AfterClass
public static void destroy() {
if (redisServer.isActive())
if (redisServer.isActive()) {
redisServer.stop();
redisClient.destroyInstance();
}
}
@Before