Skip to content

Commit c8488bf

Browse files
committed
Fixed unit test in RoundRobinAddressSetTest
1 parent 46647ab commit c8488bf

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

driver/src/main/java/org/neo4j/driver/internal/cluster/ClusterRoutingTable.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,17 @@ private Set<BoltServerAddress> servers()
7878
public synchronized RoutingTableChange update( ClusterComposition cluster )
7979
{
8080
expirationTimeout = cluster.expirationTimestamp();
81-
Set<BoltServerAddress> pre = servers();
81+
Set<BoltServerAddress> previousServers = servers();
82+
8283
readers.update( cluster.readers() );
8384
writers.update( cluster.writers() );
8485
routers.update( cluster.routers() );
85-
Set<BoltServerAddress> cur = servers();
86+
Set<BoltServerAddress> currentServers = servers();
8687

87-
Set<BoltServerAddress> added = new HashSet<>( cur );
88-
Set<BoltServerAddress> removed = new HashSet<>( pre );
89-
added.removeAll( pre );
90-
removed.removeAll( cur );
88+
Set<BoltServerAddress> added = new HashSet<>( currentServers );
89+
Set<BoltServerAddress> removed = new HashSet<>( previousServers );
90+
added.removeAll( previousServers );
91+
removed.removeAll( currentServers );
9192
return new RoutingTableChange( added, removed );
9293
}
9394

driver/src/test/java/org/neo4j/driver/internal/cluster/RoundRobinAddressSetTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import org.junit.Test;
2222

2323
import java.util.ArrayList;
24-
import java.util.HashSet;
24+
import java.util.LinkedHashSet;
2525
import java.util.List;
2626
import java.util.Set;
2727

@@ -50,7 +50,7 @@ public void shouldReturnRoundRobin() throws Exception
5050
{
5151
// given
5252
RoundRobinAddressSet set = new RoundRobinAddressSet();
53-
Set<BoltServerAddress> addresses = new HashSet<>( asList(
53+
Set<BoltServerAddress> addresses = new LinkedHashSet<>( asList(
5454
new BoltServerAddress( "one" ),
5555
new BoltServerAddress( "two" ),
5656
new BoltServerAddress( "tre" ) ) );
@@ -78,7 +78,7 @@ public void shouldReturnRoundRobin() throws Exception
7878
public void shouldPreserveOrderWhenAdding() throws Exception
7979
{
8080
// given
81-
HashSet<BoltServerAddress> servers = new HashSet<>( asList(
81+
Set<BoltServerAddress> servers = new LinkedHashSet<>( asList(
8282
new BoltServerAddress( "one" ),
8383
new BoltServerAddress( "two" ),
8484
new BoltServerAddress( "tre" ) ) );
@@ -119,7 +119,7 @@ public void shouldPreserveOrderWhenAdding() throws Exception
119119
public void shouldPreserveOrderWhenRemoving() throws Exception
120120
{
121121
// given
122-
HashSet<BoltServerAddress> servers = new HashSet<>( asList(
122+
Set<BoltServerAddress> servers = new LinkedHashSet<>( asList(
123123
new BoltServerAddress( "one" ),
124124
new BoltServerAddress( "two" ),
125125
new BoltServerAddress( "tre" ) ) );
@@ -151,7 +151,7 @@ public void shouldPreserveOrderWhenRemoving() throws Exception
151151
public void shouldPreserveOrderWhenRemovingThroughUpdate() throws Exception
152152
{
153153
// given
154-
HashSet<BoltServerAddress> servers = new HashSet<>( asList(
154+
Set<BoltServerAddress> servers = new LinkedHashSet<>( asList(
155155
new BoltServerAddress( "one" ),
156156
new BoltServerAddress( "two" ),
157157
new BoltServerAddress( "tre" ) ) );

0 commit comments

Comments
 (0)