File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
driver-core/src/main/com/mongodb/internal/connection Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 2020import com .mongodb .lang .Nullable ;
2121import org .bson .BsonDocument ;
2222
23+ import java .util .concurrent .locks .ReentrantLock ;
24+
25+ import static com .mongodb .internal .Locks .withLock ;
2326import static com .mongodb .internal .connection .ClientMetadataHelper .createClientMetadataDocument ;
2427import static com .mongodb .internal .connection .ClientMetadataHelper .updateClientMedataDocument ;
2528
2932 * <p>This class is not part of the public API and may be removed or changed at any time</p>
3033 */
3134public class ClientMetadata {
35+ private final ReentrantLock updateLock = new ReentrantLock ();
3236 private volatile BsonDocument clientMetadataBsonDocument ;
3337
3438 public ClientMetadata (@ Nullable final String applicationName , final MongoDriverInformation mongoDriverInformation ) {
@@ -43,7 +47,9 @@ public BsonDocument getBsonDocument() {
4347 }
4448
4549 public void append (final MongoDriverInformation mongoDriverInformation ) {
46- this .clientMetadataBsonDocument = updateClientMedataDocument (clientMetadataBsonDocument , mongoDriverInformation );
50+ withLock (updateLock , () ->
51+ this .clientMetadataBsonDocument = updateClientMedataDocument (clientMetadataBsonDocument , mongoDriverInformation )
52+ );
4753 }
4854}
4955
You can’t perform that action at this time.
0 commit comments