Skip to content

Add Client Metadata Update Support. #1708

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

Merged
merged 48 commits into from
Jul 2, 2025
Merged
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
9753f28
Add Client Metadata update support.
vbabanin May 6, 2025
889d5c8
Add prose tests.
vbabanin May 8, 2025
4b3065c
Add prose tests.
vbabanin May 8, 2025
2a684bf
Add ClientMetadata entity.
vbabanin May 8, 2025
28c1844
Update tests.
vbabanin May 8, 2025
371ce0b
Merge branch 'main' into JAVA-5854
vbabanin May 8, 2025
972fe9d
Fix tests.
vbabanin May 8, 2025
bcf9cc8
Fix tests.
vbabanin May 8, 2025
179b262
Spotless fix.
vbabanin May 8, 2025
bc43ba0
Skip tests when auth is enabled.
vbabanin May 9, 2025
3f5fc91
Apply Scala spotless.
vbabanin May 9, 2025
61192d8
Update tests.
vbabanin May 10, 2025
e9f8dd6
Fix tests.
vbabanin May 10, 2025
95c1bb1
Add parametrized tests.
vbabanin May 19, 2025
dd63a49
Apply Kotlin spotless.
vbabanin May 19, 2025
89d67bb
Move update to separate variables.
vbabanin May 19, 2025
8a18d39
Merge branch 'main' into JAVA-5854
vbabanin May 20, 2025
f296d0c
Merge branch 'main' into JAVA-5854
vbabanin May 20, 2025
a8dc4fb
Add lock for updates.
vbabanin May 21, 2025
8ade58b
Clone document before passing it as an argument.
vbabanin May 21, 2025
71350fa
Rename to "appendMetadata".
vbabanin May 21, 2025
9890aa1
Add ReadWriteLock and rename method.
vbabanin May 27, 2025
28f7d88
Add parametrized tests.
vbabanin Jun 4, 2025
246a040
Add readLock.
vbabanin Jun 4, 2025
8a58294
Fix readLock issue.
vbabanin Jun 4, 2025
15ecef8
Merge branch 'main' into JAVA-5854
vbabanin Jun 4, 2025
5c7a6e3
Add Kotlin and Scala API.
vbabanin Jun 6, 2025
f466d08
Add unified tests.
vbabanin Jun 10, 2025
3132541
Merge branch 'main' into JAVA-5854
vbabanin Jun 10, 2025
d961447
Fix static checks.
vbabanin Jun 10, 2025
74d8558
Change specification submodule commit.
vbabanin Jun 10, 2025
31ef18e
Revert specifications submodule URL to upstream repository.
vbabanin Jun 17, 2025
38ba5e6
Update specifications submodule commit hash.
vbabanin Jun 17, 2025
edafc54
Merge branch 'main' into JAVA-5854
vbabanin Jun 17, 2025
6aa0a1e
Merge branch 'main' into JAVA-5854
vbabanin Jun 17, 2025
dab5451
Remove duplicate import of CLIENT_METADATA in MultiServerClusterSpeci…
vbabanin Jun 17, 2025
1550122
Merge branch 'main' into JAVA-5854
vbabanin Jun 19, 2025
b5c4c20
Remove ClientMetadataHelper.
vbabanin Jun 20, 2025
b6b4d67
Update native-image.properties.
vbabanin Jun 20, 2025
d43972d
Refactor tests to use JUnit assertions and remove unused dependencies.
vbabanin Jun 24, 2025
73bdbd8
Fix test.
vbabanin Jun 24, 2025
66a5913
Add internal driver information.
vbabanin Jun 25, 2025
26246f0
Fix tests.
vbabanin Jun 25, 2025
843d890
Merge branch 'main' into JAVA-5854
vbabanin Jun 25, 2025
850ebe7
Add metadata logging.
vbabanin Jun 26, 2025
d0cabe4
Merge branch 'main' into JAVA-5854
vbabanin Jun 30, 2025
cb40b6a
Add test assertion.
vbabanin Jun 30, 2025
c44200f
Fix GSSAPI test.
vbabanin Jun 30, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add lock for updates.
  • Loading branch information
vbabanin committed May 21, 2025
commit a8dc4fbdb2445c1d5c110f9b8ef50a7e70ea4b54
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import com.mongodb.lang.Nullable;
import org.bson.BsonDocument;

import java.util.concurrent.locks.ReentrantLock;

import static com.mongodb.internal.Locks.withLock;
import static com.mongodb.internal.connection.ClientMetadataHelper.createClientMetadataDocument;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have a proper ClientMetadata class that is meant to be instantiated, it seems like we no longer need a separate ClientMetadataHelper class, instead moving the methods of that class into this one.

import static com.mongodb.internal.connection.ClientMetadataHelper.updateClientMedataDocument;

Expand All @@ -29,6 +32,7 @@
* <p>This class is not part of the public API and may be removed or changed at any time</p>
*/
public class ClientMetadata {
private final ReentrantLock updateLock = new ReentrantLock();
private volatile BsonDocument clientMetadataBsonDocument;
Copy link
Contributor

@nhachicha nhachicha May 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove the volatile, then I think you need to use the updateLock.readLock() in getBsonDocument

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I intended to use the readLock() here. Thanks for catching that - updated accordingly!


public ClientMetadata(@Nullable final String applicationName, final MongoDriverInformation mongoDriverInformation) {
Expand All @@ -43,7 +47,9 @@ public BsonDocument getBsonDocument() {
}

public void append(final MongoDriverInformation mongoDriverInformation) {
this.clientMetadataBsonDocument = updateClientMedataDocument(clientMetadataBsonDocument, mongoDriverInformation);
withLock(updateLock, () ->
this.clientMetadataBsonDocument = updateClientMedataDocument(clientMetadataBsonDocument, mongoDriverInformation)
);
}
}