Skip to content

Commit e62637f

Browse files
committed
[JAVA-224]: Java driver doesn't automatically discover replica set passive nodes
1 parent a6e3ce4 commit e62637f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/com/mongodb/ReplicaSetStatus.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ synchronized void update(Set<Node> seenNodes){
134134
_isSecondary = res.getBoolean( "secondary" , false );
135135
_lastPrimarySignal = res.getString( "primary" );
136136

137-
if ( res.containsKey( "hosts" ) ){
137+
if ( res.containsField( "hosts" ) ){
138138
for ( Object x : (List)res.get("hosts") ){
139139
String host = x.toString();
140140
Node node = _addIfNotHere(host);
@@ -143,6 +143,14 @@ synchronized void update(Set<Node> seenNodes){
143143
}
144144
}
145145

146+
if ( res.containsField( "passives" ) ){
147+
for ( Object x : (List)res.get("passives") ){
148+
String host = x.toString();
149+
Node node = _addIfNotHere(host);
150+
if (node != null && seenNodes != null)
151+
seenNodes.add(node);
152+
}
153+
}
146154
}
147155
catch ( MongoException e ){
148156
Throwable root = e;

0 commit comments

Comments
 (0)