Skip to content

Commit 446f8ff

Browse files
committed
Address review feedback
- Reuse single OperationContext in SingleServerClusterSpecification instead of creating two independent instances - Preserve srvResolutionException when creating filtered ClusterDescription in DeprioritizingSelector JAVA-6021
1 parent ae8d201 commit 446f8ff

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

driver-core/src/main/com/mongodb/internal/connection/OperationContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ public List<ServerDescription> select(final ClusterDescription clusterDescriptio
284284
new ClusterDescription(
285285
clusterDescription.getConnectionMode(),
286286
clusterDescription.getType(),
287+
clusterDescription.getSrvResolutionException(),
287288
nonDeprioritizedServerDescriptions,
288289
clusterDescription.getClusterSettings(),
289290
clusterDescription.getServerSettings()));

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ class SingleServerClusterSpecification extends Specification {
7878
sendNotification(firstServer, STANDALONE)
7979

8080
then:
81-
cluster.getServersSnapshot(createOperationContext()
82-
.getTimeoutContext()
83-
.computeServerSelectionTimeout(),
84-
createOperationContext().getTimeoutContext()).getServer(firstServer) == factory.getServer(firstServer)
81+
def operationContext = createOperationContext()
82+
cluster.getServersSnapshot(operationContext.getTimeoutContext().computeServerSelectionTimeout(),
83+
operationContext.getTimeoutContext()).getServer(firstServer) == factory.getServer(firstServer)
8584

8685
cleanup:
8786
cluster?.close()
@@ -95,8 +94,9 @@ class SingleServerClusterSpecification extends Specification {
9594
cluster.close()
9695

9796
when:
98-
cluster.getServersSnapshot(createOperationContext().getTimeoutContext().computeServerSelectionTimeout(),
99-
createOperationContext().getTimeoutContext())
97+
def operationContext = createOperationContext()
98+
cluster.getServersSnapshot(operationContext.getTimeoutContext().computeServerSelectionTimeout(),
99+
operationContext.getTimeoutContext())
100100

101101
then:
102102
thrown(IllegalStateException)

0 commit comments

Comments
 (0)