@@ -92,13 +92,11 @@ public class Mongo {
9292
9393 private final Bytes .OptionHolder optionHolder ;
9494
95- private final Cluster cluster ;
9695 private final BufferProvider bufferProvider = new PowerOfTwoBufferPool ();
9796
9897 private final ConcurrentLinkedQueue <ServerCursorAndNamespace > orphanedCursors = new ConcurrentLinkedQueue <ServerCursorAndNamespace >();
9998 private final ExecutorService cursorCleaningService ;
10099 private final MongoClientDelegate delegate ;
101- private final ServerSessionPool serverSessionPool ;
102100
103101 /**
104102 * Creates a Mongo instance based on a (single) mongodb node (localhost, default port)
@@ -312,8 +310,6 @@ public Mongo(
312310 }
313311
314312 Mongo (final Cluster cluster , final MongoClientOptions options , final List <MongoCredential > credentialsList ) {
315- this .cluster = cluster ;
316- this .serverSessionPool = new ServerSessionPool (cluster );
317313 this .options = options ;
318314 this .readPreference = options .getReadPreference ();
319315 this .writeConcern = options .getWriteConcern ();
@@ -392,7 +388,7 @@ public ReadPreference getReadPreference() {
392388 * @throws MongoException if there's a failure
393389 */
394390 public List <ServerAddress > getAllAddress () {
395- return cluster .getSettings ().getHosts ();
391+ return delegate . getCluster () .getSettings ().getHosts ();
396392 }
397393
398394 /**
@@ -406,7 +402,7 @@ public List<ServerAddress> getServerAddressList() {
406402 }
407403
408404 private ClusterDescription getClusterDescription () {
409- return cluster .getDescription ();
405+ return delegate . getCluster () .getDescription ();
410406 }
411407
412408 /**
@@ -447,7 +443,7 @@ public MongoOptions getMongoOptions() {
447443 public ReplicaSetStatus getReplicaSetStatus () {
448444 ClusterDescription clusterDescription = getClusterDescription ();
449445 return clusterDescription .getType () == REPLICA_SET && clusterDescription .getConnectionMode () == MULTIPLE
450- ? new ReplicaSetStatus (cluster ) : null ; // this is intended behavior in 2.x
446+ ? new ReplicaSetStatus (delegate . getCluster () ) : null ; // this is intended behavior in 2.x
451447 }
452448
453449
@@ -530,8 +526,7 @@ public void dropDatabase(final String dbName) {
530526 * databases obtained from it can no longer be used.
531527 */
532528 public void close () {
533- serverSessionPool .close ();
534- cluster .close ();
529+ delegate .close ();
535530 if (cursorCleaningService != null ) {
536531 cursorCleaningService .shutdownNow ();
537532 }
@@ -764,11 +759,11 @@ private static ClusterSettings getClusterSettings(final List<ServerAddress> seed
764759 }
765760
766761 Cluster getCluster () {
767- return cluster ;
762+ return delegate . getCluster () ;
768763 }
769764
770765 ServerSessionPool getServerSessionPool () {
771- return serverSessionPool ;
766+ return delegate . getServerSessionPool () ;
772767 }
773768
774769 Bytes .OptionHolder getOptionHolder () {
@@ -814,7 +809,7 @@ public void run() {
814809 private void cleanCursors () {
815810 ServerCursorAndNamespace cur ;
816811 while ((cur = orphanedCursors .poll ()) != null ) {
817- ReadWriteBinding binding = new SingleServerBinding (cluster , cur .serverCursor .getAddress ());
812+ ReadWriteBinding binding = new SingleServerBinding (delegate . getCluster () , cur .serverCursor .getAddress ());
818813 try {
819814 ConnectionSource source = binding .getReadConnectionSource ();
820815 try {
0 commit comments