-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Remove internal use of MongoNamespace.COMMAND_COLLECTION_NAME #1782
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
Conversation
This is a remnant of the pre-OP_MSG wire protocol, which required a synthetic collection name for most commands. It's no longer needed, except for the last remaining bit where the driver uses OP_QUERY for the first message in the connection handshake. JAVA-5939
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Show resolved
Hide resolved
|
||
<D> MongoOperationPublisher<D> withDatabaseAndDocumentClass(final String name, final Class<D> documentClass) { | ||
return withNamespaceAndDocumentClass(new MongoNamespace(notNull("name", name), "ignored"), | ||
return withNamespaceAndDocumentClass(new MongoNamespace(notNull("name", name), "_ignored"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just changed this to be consistent with other similar spots in the driver.
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Show resolved
Hide resolved
driver-core/src/main/com/mongodb/internal/connection/CommandMessage.java
Show resolved
Hide resolved
…ssage.java Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR removes the internal use of MongoNamespace.COMMAND_COLLECTION_NAME
throughout the MongoDB Java driver codebase. The change eliminates a remnant from the pre-OP_MSG wire protocol that required synthetic collection names for commands. The constant is replaced with hardcoded collection name values or database names where appropriate, since modern MongoDB communication primarily uses the OP_MSG protocol which doesn't require this synthetic naming convention.
Key changes include:
- Replacing
MongoNamespace.COMMAND_COLLECTION_NAME
usage with literal values like"_ignored"
in test contexts and"$cmd"
for actual command operations - Updating
CommandMessage
constructor to accept database names directly instead of fullMongoNamespace
objects - Simplifying the
RequestMessage
class hierarchy by removing collection name tracking
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
CommandMessage.java | Modified constructor to accept database name instead of MongoNamespace, updated internal logic to construct command namespace when needed |
RequestMessage.java | Removed collection name field and associated constructors/methods to simplify the message hierarchy |
CommandProtocolImpl.java | Updated to work with database names instead of MongoNamespace objects |
Various test files | Replaced hardcoded references to synthetic collection names with "_ignored" placeholder values |
DefaultServerMonitor.java, CommandHelper.java | Updated command message creation to use database names directly |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This removes a remnant of the pre-OP_MSG wire protocol, which required a synthetic collection name for most commands. It's no longer needed, except for the last remaining bit where the driver uses OP_QUERY for the first message in the connection handshake.
JAVA-5939