Skip to content

Commit f0943d7

Browse files
author
Myron Scott
authored
Merge pull request #1136 from ramsai1729/voter-fix
Use latest topology during re-registration
2 parents 4531ef8 + 3ebd746 commit f0943d7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

voter/src/main/java/org/terracotta/voter/ActiveVoter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
import java.util.stream.Collectors;
4848

4949
import static java.util.Arrays.asList;
50-
import static java.util.stream.Collectors.toList;
50+
import static java.util.stream.Collectors.toCollection;
51+
5152
/**
5253
* ActiveVoter votes only for the active it originally connects to. If the active disconnects,
5354
* 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() {
9697
private Thread voterThread(CompletableFuture<VoterStatus> voterStatus, Optional<Properties> connectionProps, String... hostPorts) {
9798
return new Thread(() -> {
9899
ExecutorService executorService = Executors.newCachedThreadPool();
99-
List<ClientVoterManager> clientVoterManagers = Stream.of(hostPorts).map(clientVoterManagerFactory).collect(toList());
100+
Stream.of(hostPorts).map(clientVoterManagerFactory).collect(toCollection(() -> voterManagers));
100101
existingTopology.addAll(new HashSet<>(asList(hostPorts)));
101-
voterManagers.addAll(clientVoterManagers);
102102
registrationLatch.addAll(new HashSet<>(asList(hostPorts)));
103103
try {
104104
while (!Thread.currentThread().isInterrupted()) {
105-
ClientVoterManager currentActive = registerWithActive(id, clientVoterManagers, connectionProps);
105+
ClientVoterManager currentActive = registerWithActive(id, voterManagers, connectionProps);
106106
activeClientVoterManager = currentActive;
107107
active = true;
108108
LOGGER.info("{} registered with the active: {}", this, currentActive.getTargetHostPort());

0 commit comments

Comments
 (0)