|
47 | 47 | import java.util.stream.Collectors;
|
48 | 48 |
|
49 | 49 | import static java.util.Arrays.asList;
|
50 |
| -import static java.util.stream.Collectors.toList; |
| 50 | +import static java.util.stream.Collectors.toCollection; |
| 51 | + |
51 | 52 | /**
|
52 | 53 | * ActiveVoter votes only for the active it originally connects to. If the active disconnects,
|
53 | 54 | * vote for the next server requesting vote. If the server with the new vote becomes the new active,
|
@@ -96,13 +97,12 @@ public ActiveVoter start() {
|
96 | 97 | private Thread voterThread(CompletableFuture<VoterStatus> voterStatus, Optional<Properties> connectionProps, String... hostPorts) {
|
97 | 98 | return new Thread(() -> {
|
98 | 99 | ExecutorService executorService = Executors.newCachedThreadPool();
|
99 |
| - List<ClientVoterManager> clientVoterManagers = Stream.of(hostPorts).map(clientVoterManagerFactory).collect(toList()); |
| 100 | + Stream.of(hostPorts).map(clientVoterManagerFactory).collect(toCollection(() -> voterManagers)); |
100 | 101 | existingTopology.addAll(new HashSet<>(asList(hostPorts)));
|
101 |
| - voterManagers.addAll(clientVoterManagers); |
102 | 102 | registrationLatch.addAll(new HashSet<>(asList(hostPorts)));
|
103 | 103 | try {
|
104 | 104 | while (!Thread.currentThread().isInterrupted()) {
|
105 |
| - ClientVoterManager currentActive = registerWithActive(id, clientVoterManagers, connectionProps); |
| 105 | + ClientVoterManager currentActive = registerWithActive(id, voterManagers, connectionProps); |
106 | 106 | activeClientVoterManager = currentActive;
|
107 | 107 | active = true;
|
108 | 108 | LOGGER.info("{} registered with the active: {}", this, currentActive.getTargetHostPort());
|
|
0 commit comments