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 20
20
import com .mongodb .lang .Nullable ;
21
21
import org .bson .BsonDocument ;
22
22
23
+ import java .util .concurrent .locks .ReentrantLock ;
24
+
25
+ import static com .mongodb .internal .Locks .withLock ;
23
26
import static com .mongodb .internal .connection .ClientMetadataHelper .createClientMetadataDocument ;
24
27
import static com .mongodb .internal .connection .ClientMetadataHelper .updateClientMedataDocument ;
25
28
29
32
* <p>This class is not part of the public API and may be removed or changed at any time</p>
30
33
*/
31
34
public class ClientMetadata {
35
+ private final ReentrantLock updateLock = new ReentrantLock ();
32
36
private volatile BsonDocument clientMetadataBsonDocument ;
33
37
34
38
public ClientMetadata (@ Nullable final String applicationName , final MongoDriverInformation mongoDriverInformation ) {
@@ -43,7 +47,9 @@ public BsonDocument getBsonDocument() {
43
47
}
44
48
45
49
public void append (final MongoDriverInformation mongoDriverInformation ) {
46
- this .clientMetadataBsonDocument = updateClientMedataDocument (clientMetadataBsonDocument , mongoDriverInformation );
50
+ withLock (updateLock , () ->
51
+ this .clientMetadataBsonDocument = updateClientMedataDocument (clientMetadataBsonDocument , mongoDriverInformation )
52
+ );
47
53
}
48
54
}
49
55
You can’t perform that action at this time.
0 commit comments