Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configuring the monitoring protocol to use; use the polling protocol in a FaaS environment by default #1313
Allow configuring the monitoring protocol to use; use the polling protocol in a FaaS environment by default #1313
Changes from 1 commit
33631e1
d7aa01c
63562c6
1e74b01
640fd79
b7e461f
91a6ebb
2f3cdcb
bc589fb
315d66c
00c05ff
fa83aba
ac346ab
b372ca9
128741d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this check "connection == null" not needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I had proven to myself that the check was redundant by transforming to
and then allowing Intellij to simplify the expression, but when I tried it again IntelliJ didn't offer the simplification.
This is a truly horrible conditional, and has been the source of at least one bug that I remember.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It had no effect, so I removed it. The following demonstrates why the
connection == null
expression had no effect.Here is the original conditional, but reformatted to simplify perception:
It consists of three Boolean expressions ORed (
||
) together. Only the first one of those is modified in the PR.connection == null
expression asx
.shouldStreamResponses(currentServerDescription)
andcurrentServerDescription.getTopologyVersion() != null
are equivalent (well, were equivalent at the time of the commit that simplified the expression). Let's alias them ass
.Now the first ORed Boolean expression can be written as
If
s
isfalse
, this expression evaluates tofalse
. Ifs
istrue
, this expression evaluates to the same value ascurrentServerDescription.getType() != UNKNOWN
. As you can see,x
affects the outcome is neither case, and the expression can be simplified toThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification, @stIncMale. Now i see, It is indeed redundant check.
i am curious about the original purpose of this check, given it wasn't functional. My assumption was that it might have aimed to bypass
waitForNext()
on lookup failure as connection is nullified in lookup method. However, the presence of(currentServerDescription.getException() instanceof MongoSocketException && previousServerDescription.getType() != UNKNOWN)
seems to cover scenario aligning with the spec, which mandates immediate retry on network errors when the server was previously in a known state.Feel free to resolve the conversation if @jyemin has no further comments.