Skip to content

Commit 9321007

Browse files
rozzajyemin
authored andcommitted
Re-enabled ReplyMessage.responseTo check
JAVA-3061
1 parent 61282f4 commit 9321007

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.mongodb.internal.connection;
1818

19+
import com.mongodb.MongoInternalException;
1920
import org.bson.BsonBinaryReader;
2021
import org.bson.codecs.Decoder;
2122
import org.bson.codecs.DecoderContext;
@@ -25,6 +26,8 @@
2526
import java.util.ArrayList;
2627
import java.util.List;
2728

29+
import static java.lang.String.format;
30+
2831
/**
2932
* An OP_REPLY message.
3033
*
@@ -58,12 +61,10 @@ public ReplyMessage(final ResponseBuffers responseBuffers, final Decoder<T> deco
5861
}
5962

6063
ReplyMessage(final ReplyHeader replyHeader, final long requestId) {
61-
// Todo - find out why
62-
// if (requestId != replyHeader.getResponseTo()) {
63-
// throw new MongoInternalException(format("The responseTo (%d) in the response does not match the requestId (%d) in the "
64-
// + "request", replyHeader.getResponseTo(), requestId));
65-
// }
66-
64+
if (requestId != replyHeader.getResponseTo()) {
65+
throw new MongoInternalException(format("The responseTo (%d) in the response does not match the requestId (%d) in the "
66+
+ "request", replyHeader.getResponseTo(), requestId));
67+
}
6768
this.replyHeader = replyHeader;
6869

6970
documents = new ArrayList<T>(replyHeader.getNumberReturned());

driver-core/src/test/unit/com/mongodb/internal/connection/ReplyMessageTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import com.mongodb.MongoInternalException;
2020
import org.bson.ByteBufNIO;
2121
import org.bson.Document;
22-
import org.junit.Ignore;
2322
import org.junit.Test;
2423

2524
import java.nio.Buffer;
@@ -30,7 +29,6 @@
3029

3130
public class ReplyMessageTest {
3231

33-
@Ignore // Todo - return once embedded ReplyMessage check re-enabled.
3432
@Test(expected = MongoInternalException.class)
3533
public void shouldThrowExceptionIfRequestIdDoesNotMatchResponseTo() {
3634
int badResponseTo = 34565;

0 commit comments

Comments
 (0)