Skip to content

Conversation

jyemin
Copy link
Collaborator

@jyemin jyemin commented Aug 11, 2025

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

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
@jyemin jyemin self-assigned this Aug 11, 2025
@jyemin jyemin requested a review from a team as a code owner August 11, 2025 21:09
@jyemin jyemin requested review from NathanQingyangXu and removed request for a team August 11, 2025 21:09

<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"),
Copy link
Collaborator Author

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.

@jyemin jyemin requested a review from Copilot August 12, 2025 11:57
Copilot

This comment was marked as outdated.

@jyemin jyemin requested a review from Copilot August 13, 2025 17:59
Copy link
Contributor

@Copilot Copilot AI left a 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 full MongoNamespace 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.

@jyemin jyemin merged commit 04996f0 into mongodb:main Aug 13, 2025
3 of 4 checks passed
@jyemin jyemin deleted the JAVA-5939 branch August 13, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants