-
Notifications
You must be signed in to change notification settings - Fork 99
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
Avoid mutating arguments passed into various methods #39
Comments
I'd agree that's breaking the prinicple of least surprise (and then some). The Id generation and save should effectively be an atomic operation (yeah, yeah, we're not in txn SQL now Dorothy) |
Also bear in mind that the mongo client might be used remotely using a service proxy where any changes to the passed in JsonObject won't be visible. |
Postponed to 3.3.0 |
Signed-off-by: meshuga <[email protected]>
Today I discovered this side effect in my code during insert operation. I don't consider it as a bug and some people might use it as a feature, so copying the document might break compatibility. I've made a PR with updated Javadoc to inform other developers about this "feature" - #61 |
#39 Added information about document mutabi…
We still believe it is a bug as this won't work correctly over the event bus. That said we will need to carefully note that a fix will be breaking backwards compatibility. |
I've just spent half a Sunday on what I thought being a bug in my code because manipulated data by |
@mszmurlo We don't have an active maintainer looking at this - so relying on community PR's at this stage. |
This would be a breaking change so if a fix was to occur it would need to be in the next major version |
Currently we will mutate JsonObjects that are passed in to some methods, most notably we will add _id fields to objects when calling a save. This will happen even if the save fails, I believe this could potentially lead to dangerous behaviour.
My previous logic was that if a save failed I would retry, however by this point an _id field had already been placed on the document, so the second call would have subtly different behaviour as now I was saving an object that had an _id field on it.
I would propose making a copy of all arguments passed in to avoid mutating them.
The text was updated successfully, but these errors were encountered: