Skip to content

Commit ac1c120

Browse files
authored
JAVA-6035: Add backpressure flag to connection handshake (#1906)
1 parent e5d8668 commit ac1c120

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ private InternalConnectionInitializationDescription createInitializationDescript
172172

173173
private BsonDocument createHelloCommand(final Authenticator authenticator, final InternalConnection connection) {
174174
BsonDocument helloCommandDocument = new BsonDocument(getHandshakeCommandName(), new BsonInt32(1))
175-
.append("helloOk", BsonBoolean.TRUE);
175+
.append("helloOk", BsonBoolean.TRUE)
176+
.append("backpressure", BsonBoolean.TRUE);
176177
if (clientMetadataDocument != null) {
177178
helloCommandDocument.append("client", clientMetadataDocument);
178179
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ class InternalStreamConnectionInitializerSpecification extends Specification {
201201
def initializer = new InternalStreamConnectionInitializer(SINGLE, null, clientMetadataDocument, [], null)
202202
def expectedHelloCommandDocument = new BsonDocument(LEGACY_HELLO, new BsonInt32(1))
203203
.append('helloOk', BsonBoolean.TRUE)
204+
.append('backpressure', BsonBoolean.TRUE)
204205
.append('\$db', new BsonString('admin'))
205206
if (clientMetadataDocument != null) {
206207
expectedHelloCommandDocument.append('client', clientMetadataDocument)
@@ -233,6 +234,7 @@ class InternalStreamConnectionInitializerSpecification extends Specification {
233234
def initializer = new InternalStreamConnectionInitializer(SINGLE, null, null, compressors, null)
234235
def expectedHelloCommandDocument = new BsonDocument(LEGACY_HELLO, new BsonInt32(1))
235236
.append('helloOk', BsonBoolean.TRUE)
237+
.append('backpressure', BsonBoolean.TRUE)
236238
.append('\$db', new BsonString('admin'))
237239

238240
def compressionArray = new BsonArray()
@@ -403,7 +405,8 @@ class InternalStreamConnectionInitializerSpecification extends Specification {
403405
((SpeculativeAuthenticator) authenticator).getSpeculativeAuthenticateResponse() == null
404406
((SpeculativeAuthenticator) authenticator)
405407
.createSpeculativeAuthenticateCommand(internalConnection) == null
406-
BsonDocument.parse("{$LEGACY_HELLO: 1, helloOk: true, '\$db': 'admin'}") == decodeCommand(internalConnection.getSent()[0])
408+
BsonDocument.parse("{$LEGACY_HELLO: 1, helloOk: true, backpressure: true, '\$db': 'admin'}") ==
409+
decodeCommand(internalConnection.getSent()[0])
407410

408411
where:
409412
async << [true, false]
@@ -500,7 +503,7 @@ class InternalStreamConnectionInitializerSpecification extends Specification {
500503

501504
def createHelloCommand(final String firstClientChallenge, final String mechanism,
502505
final boolean hasSaslSupportedMechs) {
503-
String hello = "{$LEGACY_HELLO: 1, helloOk: true, " +
506+
String hello = "{$LEGACY_HELLO: 1, helloOk: true, backpressure: true, " +
504507
(hasSaslSupportedMechs ? 'saslSupportedMechs: "database.user", ' : '') +
505508
(mechanism == 'MONGODB-X509' ?
506509
'speculativeAuthenticate: { authenticate: 1, ' +

0 commit comments

Comments
 (0)