-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Introduce BsonUtil.mutableDeepCopy
#1081
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
Conversation
rozza
left a comment
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.
LGTM - please also add a Jira ticket to associate with this change.
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'm not so sure about this, and would like to discuss it in the context of a Jira ticket. |
d1a0c31 to
a525a64
Compare
|
Instead of modifying |
BsonDocument.clone returns a mutable deep copyUtil.mutableDeepCopy
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.
Not sure I like the lack of description in name of the Util class - suggest BsonDocumentHelper or BsonDocumentUtil. Will make it more discoverable in the future.
I like the tests use a mix of BsonValue (BsonDocumentWrapper, RawBsonDocument etc) types.
Other than the name - LGTM
JAVA-4874
|
@rozza Renamed to |
Util.mutableDeepCopyBsonUtil.mutableDeepCopy
jyemin
left a comment
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.
LGTM
Currently we have at least two places (that I know of) where we rely on
BsonDocument.clonereturning not only a deep copy, but mutable deep copy:AbstractConstructibleBson.newMergedClientEncryption.createEncryptedCollectionintroduced in Add theClientEncryption.createEncryptedCollectionhelper method #1079.@rozza pointed out that
RawBsonDocumentbreaks the "mutable" part and can come from users: thecloneIsDeepCopyAndMutabletest added in this PR demonstrates this.RawBsonDocument.clonereturnsBsonDocument(notRawBsonDocument), and documents nothing about its behavior (neither doesBsonDocument.clone). So while there may be different approaches of solving the problem, these facts allow for the straightforward approach to fix the problem proposed in this PR.JAVA-4874