Skip to content

Commit 8614945

Browse files
committed
Ensure all CommandEvents have same order of params
JAVA-4875
1 parent 1d2d782 commit 8614945

File tree

5 files changed

+27
-26
lines changed

5 files changed

+27
-26
lines changed

driver-core/src/main/com/mongodb/event/CommandFailedEvent.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,19 @@ public final class CommandFailedEvent extends CommandEvent {
3737
/**
3838
* Construct an instance.
3939
*
40-
* @param requestContext the request context
41-
* @param operationId the operation id
42-
* @param requestId the request id
40+
* @param requestContext the request context
41+
* @param operationId the operation id
42+
* @param requestId the request id
4343
* @param connectionDescription the connection description
44-
* @param commandName the command name
45-
* @param elapsedTimeNanos the non-negative elapsed time in nanoseconds for the operation to complete
46-
* @param throwable the throwable cause of the failure
44+
* @param databaseName the database name
45+
* @param commandName the command name
46+
* @param elapsedTimeNanos the non-negative elapsed time in nanoseconds for the operation to complete
47+
* @param throwable the throwable cause of the failure
4748
* @since 4.11
4849
*/
4950
public CommandFailedEvent(@Nullable final RequestContext requestContext, final long operationId, final int requestId,
50-
final ConnectionDescription connectionDescription, final String commandName,
51-
final String databaseName, final long elapsedTimeNanos, final Throwable throwable) {
51+
final ConnectionDescription connectionDescription, final String databaseName, final String commandName,
52+
final long elapsedTimeNanos, final Throwable throwable) {
5253
super(requestContext, operationId, requestId, connectionDescription, commandName, databaseName);
5354
isTrueArgument("elapsed time is not negative", elapsedTimeNanos >= 0);
5455
this.elapsedTimeNanos = elapsedTimeNanos;

driver-core/src/main/com/mongodb/event/CommandSucceededEvent.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ public final class CommandSucceededEvent extends CommandEvent {
3737
/**
3838
* Construct an instance.
3939
*
40-
* @param requestContext the request context
41-
* @param operationId the operation id
42-
* @param requestId the request id
40+
* @param requestContext the request context
41+
* @param operationId the operation id
42+
* @param requestId the request id
4343
* @param connectionDescription the connection description
44-
* @param commandName the command name
45-
* @param databaseName the database name
46-
* @param response the command response
47-
* @param elapsedTimeNanos the non-negative elapsed time in nanoseconds for the operation to complete
44+
* @param databaseName the database name
45+
* @param commandName the command name
46+
* @param response the command response
47+
* @param elapsedTimeNanos the non-negative elapsed time in nanoseconds for the operation to complete
4848
* @since 4.11
4949
*/
5050
public CommandSucceededEvent(@Nullable final RequestContext requestContext, final long operationId, final int requestId,
51-
final ConnectionDescription connectionDescription, final String commandName,
52-
final String databaseName, final BsonDocument response, final long elapsedTimeNanos) {
51+
final ConnectionDescription connectionDescription, final String databaseName, final String commandName,
52+
final BsonDocument response, final long elapsedTimeNanos) {
5353
super(requestContext, operationId, requestId, connectionDescription, commandName, databaseName);
5454
this.response = response;
5555
isTrueArgument("elapsed time is not negative", elapsedTimeNanos >= 0);

driver-core/src/main/com/mongodb/internal/connection/ProtocolHelper.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ static void sendCommandSucceededEvent(final RequestMessage message, final String
295295
notNull("requestContext", requestContext);
296296
try {
297297
commandListener.commandSucceeded(new CommandSucceededEvent(getRequestContextForEvent(requestContext),
298-
operationContext.getId(), message.getId(), connectionDescription, commandName, databaseName, response,
298+
operationContext.getId(), message.getId(), connectionDescription, databaseName, commandName, response,
299299
elapsedTimeNanos));
300300
} catch (Exception e) {
301301
if (PROTOCOL_EVENT_LOGGER.isWarnEnabled()) {
@@ -311,7 +311,7 @@ static void sendCommandFailedEvent(final RequestMessage message, final String da
311311
notNull("requestContext", requestContext);
312312
try {
313313
commandListener.commandFailed(new CommandFailedEvent(getRequestContextForEvent(requestContext),
314-
operationContext.getId(), message.getId(), connectionDescription, commandName, databaseName, elapsedTimeNanos,
314+
operationContext.getId(), message.getId(), connectionDescription, databaseName, commandName, elapsedTimeNanos,
315315
throwable));
316316
} catch (Exception e) {
317317
if (PROTOCOL_EVENT_LOGGER.isWarnEnabled()) {

driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ else if (!observeSensitiveCommands) {
250250
lock.lock();
251251
try {
252252
events.add(new CommandSucceededEvent(event.getRequestContext(), event.getOperationId(), event.getRequestId(),
253-
event.getConnectionDescription(), event.getCommandName(), event.getDatabaseName(),
253+
event.getConnectionDescription(), event.getDatabaseName(), event.getCommandName(),
254254
event.getResponse() == null ? null : event.getResponse().clone(),
255255
event.getElapsedTime(TimeUnit.NANOSECONDS)));
256256
commandCompletedCondition.signal();

driver-core/src/test/unit/com/mongodb/internal/connection/LoggingCommandEventSenderSpecification.groovy

+6-6
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ class LoggingCommandEventSenderSpecification extends Specification {
7777
[
7878
new CommandStartedEvent(null, context.id, message.getId(), connectionDescription, namespace.databaseName,
7979
commandDocument.getFirstKey(), commandDocument.append('$db', new BsonString(namespace.databaseName))),
80-
new CommandSucceededEvent(null, context.id, message.getId(), connectionDescription, commandDocument.getFirstKey(),
81-
namespace.databaseName, new BsonDocument(), 1),
82-
new CommandSucceededEvent(null, context.id, message.getId(), connectionDescription, commandDocument.getFirstKey(),
83-
namespace.databaseName, replyDocument, 1),
84-
new CommandFailedEvent(null, context.id, message.getId(), connectionDescription, commandDocument.getFirstKey(),
85-
namespace.databaseName, 1, failureException)
80+
new CommandSucceededEvent(null, context.id, message.getId(), connectionDescription, namespace.databaseName,
81+
commandDocument.getFirstKey(), new BsonDocument(), 1),
82+
new CommandSucceededEvent(null, context.id, message.getId(), connectionDescription, namespace.databaseName,
83+
commandDocument.getFirstKey(), replyDocument, 1),
84+
new CommandFailedEvent(null, context.id, message.getId(), connectionDescription, namespace.databaseName,
85+
commandDocument.getFirstKey(), 1, failureException)
8686
])
8787

8888
where:

0 commit comments

Comments
 (0)