JAVA-2387: Mongo.getAddressList returns the seed list, as per the doc… · zzd4java/mongo-java-driver@8a3cbc9 · GitHub
Skip to content

Commit 8a3cbc9

Browse files
committed
JAVA-2387: Mongo.getAddressList returns the seed list, as per the documentation, instead of the list of discovered servers
1 parent 365213f commit 8a3cbc9

4 files changed

Lines changed: 35 additions & 6 deletions

File tree

driver-core/src/main/com/mongodb/connection/Cluster.java

Lines changed: 8 additions & 0 deletions

driver-core/src/test/unit/com/mongodb/connection/BaseClusterSpecification.groovy

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ class BaseClusterSpecification extends Specification {
4949
private final List<ServerAddress> allServers = [firstServer, secondServer, thirdServer]
5050
private final TestClusterableServerFactory factory = new TestClusterableServerFactory()
5151

52+
def 'should get cluster settings'() {
53+
given:
54+
def clusterSettings = builder().mode(MULTIPLE)
55+
.hosts([firstServer, secondServer, thirdServer])
56+
.serverSelectionTimeout(1, SECONDS)
57+
.serverSelector(new ServerAddressSelector(firstServer))
58+
.build()
59+
def cluster = new MultiServerCluster(new ClusterId(), clusterSettings, factory)
60+
61+
expect:
62+
cluster.getSettings() == clusterSettings
63+
}
64+
5265
def 'should compose server selector passed to selectServer with server selector in cluster settings'() {
5366
given:
5467
def cluster = new MultiServerCluster(new ClusterId(),

driver/src/main/com/mongodb/Mongo.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,7 @@ public ReadPreference getReadPreference() {
390390
* @throws MongoException if there's a failure
391391
*/
392392
public List<ServerAddress> getAllAddress() {
393-
//TODO It should return the address list without auto-discovered nodes. Not sure if it's required. Maybe users confused with name.
394-
return getServerAddressList();
393+
return cluster.getSettings().getHosts();
395394
}
396395

397396
/**

driver/src/test/unit/com/mongodb/MongoConstructorsTest.java

Lines changed: 13 additions & 4 deletions

0 commit comments

Comments
 (0)