Skip to content

Commit adc6f30

Browse files
committed
Add failing unit test for deadlock issue
1 parent 8321f5d commit adc6f30

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/test/java/io/lettuce/core/cluster/topology/ClusterTopologyRefreshUnitTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import static io.lettuce.TestTags.UNIT_TEST;
2323
import static org.assertj.core.api.Assertions.*;
24+
import static org.junit.jupiter.api.Timeout.ThreadMode.SEPARATE_THREAD;
2425
import static org.mockito.ArgumentMatchers.*;
2526
import static org.mockito.Mockito.*;
2627
import static org.mockito.Mockito.anyLong;
@@ -40,6 +41,7 @@
4041
import java.util.concurrent.CompletionStage;
4142
import java.util.concurrent.TimeUnit;
4243

44+
import org.junit.jupiter.api.Assertions;
4345
import org.junit.jupiter.api.BeforeEach;
4446
import org.junit.jupiter.api.Tag;
4547
import org.junit.jupiter.api.Test;
@@ -455,6 +457,20 @@ void shouldCloseConnections() {
455457
verify(connection2).closeAsync();
456458
}
457459

460+
/**
461+
* @see <a href="https://github.com/redis/lettuce/issues/3240">Issue link</a>
462+
*/
463+
@Test
464+
@org.junit.jupiter.api.Timeout(value = 5, unit = TimeUnit.SECONDS, threadMode = SEPARATE_THREAD)
465+
void shouldHandleInvalidUrisWithoutDeadlock() {
466+
List<RedisURI> seed = Arrays.asList(RedisURI.create("redis://localhost:$(INVALID_DATA):CONFIG"),
467+
RedisURI.create("redis://localhost:$(INVALID_DATA):CONFIG"));
468+
CompletionException completionException = Assertions.assertThrows(CompletionException.class,
469+
() -> sut.loadViews(seed, Duration.ofSeconds(1), true).toCompletableFuture().join());
470+
assertThat(completionException)
471+
.hasRootCauseInstanceOf(DefaultClusterTopologyRefresh.CannotRetrieveClusterPartitions.class);
472+
}
473+
458474
@Test
459475
void undiscoveredAdditionalNodesShouldBeLastUsingClientCount() {
460476

0 commit comments

Comments
 (0)