Skip to content

Commit

Permalink
Return copy of replicas
Browse files Browse the repository at this point in the history
  • Loading branch information
acogoluegnes committed Nov 26, 2024
1 parent 062a094 commit 5afeb53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/java/com/rabbitmq/stream/impl/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -2263,9 +2263,12 @@ public Broker getLeader() {
return leader;
}

@SuppressFBWarnings("EI_EXPOSE_REP2")
public List<Broker> getReplicas() {
return replicas;
return this.replicas.isEmpty() ? Collections.emptyList() : new ArrayList<>(this.replicas);
}

boolean hasReplicas() {
return !this.replicas.isEmpty();
}

public String getStream() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ List<BrokerWrapper> findCandidateNodes(String stream, boolean forceLeader) {
}
candidates.add(new BrokerWrapper(leader, true));

if (!forceLeader && !streamMetadata.getReplicas().isEmpty()) {
if (!forceLeader && streamMetadata.hasReplicas()) {
candidates.addAll(
streamMetadata.getReplicas().stream()
.map(b -> new BrokerWrapper(b, false))
Expand Down

0 comments on commit 5afeb53

Please sign in to comment.