-
Notifications
You must be signed in to change notification settings - Fork 992
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix connection leak in cluster topology refresh implementation #721
Make sure topology/Connections class closes all referenced connections when close() is called. Original pull request: #722.
- Loading branch information
Showing
3 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/test/java/io/lettuce/core/cluster/topology/ConnectionsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.lettuce.core.cluster.topology; | ||
|
||
import static org.mockito.Mockito.verify; | ||
|
||
import io.lettuce.core.RedisURI; | ||
import io.lettuce.core.api.StatefulRedisConnection; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ConnectionsTest { | ||
|
||
@Mock | ||
private StatefulRedisConnection<String, String> connection1; | ||
|
||
@Mock | ||
private StatefulRedisConnection<String, String> connection2; | ||
|
||
@Test | ||
public void shouldCloseAllConnections() { | ||
final Connections iut = new Connections(); | ||
iut.addConnection(RedisURI.create("127.0.0.1", 7380), connection1); | ||
iut.addConnection(RedisURI.create("127.0.0.1", 7381), connection2); | ||
|
||
iut.close(); | ||
|
||
verify(connection1).close(); | ||
verify(connection2).close(); | ||
} | ||
} |