Skip to content

Commit 29ebd76

Browse files
stIncMalekatcharov
andauthored
Update driver-core/src/main/com/mongodb/internal/connection/OperationContext.java
Let's put various checks (validation, preconditions...) at the top of methods, with the operation at the bottom. Co-authored-by: Maxim Katcharov <[email protected]>
1 parent e4ffab4 commit 29ebd76

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ void updateCandidate(final ServerAddress serverAddress, final ClusterType cluste
7171
}
7272

7373
public void onAttemptFailure(final Throwable failure) {
74-
if (candidate != null && !(failure instanceof MongoConnectionPoolClearedException)) {
75-
deprioritized.add(candidate);
74+
if (candidate == null || failure instanceof MongoConnectionPoolClearedException) {
75+
candidate = null;
76+
return;
7677
}
77-
candidate = null;
78+
deprioritized.add(candidate);
7879
}
7980

8081
private static boolean isEnabled(final ClusterType clusterType) {

0 commit comments

Comments
 (0)