Skip to content
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

Skip processing of INFO.ConnectURLs when the array is empty. #352

Merged
merged 1 commit into from
Mar 17, 2018

Conversation

kozlovic
Copy link
Member

Continuation of #344. We don't want to remove discovered servers
from the pool if we get an INFO with empty array. The new servers
will send arrays with at least their own URL, but older servers
or in some situations, the array could be empty (omitted) and we
should not treat this as if there were no server at all in the
cluster.

Continuation of #344. We don't want to remove discovered servers
from the pool if we get an INFO with empty array. The new servers
will send arrays with at least their own URL, but older servers
or in some situations, the array could be empty (omitted) and we
should not treat this as if there were no server at all in the
cluster.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 95.004% when pulling e270c49 on process_info_with_empty_connect_urls into f90dee2 on master.

return err
}
// Copy content into connection's info structure.
nc.info = ncInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we replace what was there if the array is empty and we ignore it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that first, but there is no point since the array is actually only used in this function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why make a copy and not just de-marshal direct into nc.info like it was?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I was doing before, but then I realized that we should always clear before the unmarshal because otherwise, if a field of the structure is set before calling unmarshal, but is empty in the incoming protocol, then it would not be set to empty in unmarshal. In other words, for instance if ConnectURLs is not empty before the call to Unmarshal, but the incoming protocol has an empty array, after the call it would seem as if ConnectURLs was set. In that specific case it would be fine, but as a general practice I think it is bad since we may not really use what comes from the protocol if we "reuse" the nc.Info for the Unmarshal call.

@derekcollison
Copy link
Member

LGTM

@derekcollison derekcollison merged commit 282b132 into master Mar 17, 2018
@derekcollison derekcollison deleted the process_info_with_empty_connect_urls branch March 17, 2018 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants