[JAVA-3974] Async CryptBinding.retain() returns wrapped reference instead of this Created: 28/Jan/21  Updated: 28/Oct/23  Resolved: 03/Feb/21

Status: Closed
Project: Java Driver
Component/s: Reactive Streams
Affects Version/s: None
Fix Version/s: 4.3.0

Type: Improvement Priority: Major - P3
Reporter: Jeffrey Yemin Assignee: Jeffrey Yemin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Issue split
split from JAVA-3907 AsyncQueryBatchCursor does not releas... Closed
Related
related to JAVA-3975 AsyncSessionBinding.retain and Sessio... Closed
Backwards Compatibility: Fully Compatible
Documentation Changes: Not Needed

 Description   

Implementations of ReferenceCounted.retain should always return this. The implementation of com.mongodb.reactivestreams.client.internal.crypt.CryptBinding instead returns wrapped.retain().

If a caller did something like:

this.binding = binding.retain();

this could lead to bad outcomes, like failure to encrypt or decrypt documents. While it doesn't appear that any driver code actually does this right now, we should still fix this to avoid future problems.



 Comments   
Comment by Githook User [ 03/Feb/21 ]

Author:

{'name': 'Jeff Yemin', 'email': 'jeff.yemin@mongodb.com', 'username': 'jyemin'}

Message: Return `this` from CryptBinding.retain

JAVA-3974
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/605682cae738f93ae530e48defcb93479825bb01

Comment by Jeffrey Yemin [ 28/Jan/21 ]

Yes, that's true. But that class in in test code, whereas this is production code, so I wanted to call this one out separately.

Comment by Valentin Kavalenka [ 28/Jan/21 ]

AsyncSessionBinding.SessionBindingAsyncConnectionSource.retain also returns not this but wrapped.retain(). This violates the contract specified by the ReferenceCounted.retain method.

Update: created JAVA-3975 to track this one.

Generated at Thu Feb 08 09:00:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.