Skip to content

Commit 8d9f3b1

Browse files
committed
Codenarc / checkstyle fixes and cleanups
1 parent dd3b55c commit 8d9f3b1

File tree

8 files changed

+9
-79
lines changed

8 files changed

+9
-79
lines changed

driver-core/src/main/com/mongodb/internal/operation/AsyncCommandBatchCursor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ private void releaseServerAndClientResources(final AsyncConnection connection) {
309309
callbackSupplier.whenComplete(() -> {
310310
unsetServerCursor();
311311
releaseClientResources();
312-
}).whenComplete(connection::release).get((r,t) -> { /* do nothing */ });
312+
}).whenComplete(connection::release).get((r, t) -> { /* do nothing */ });
313313
}
314314

315315
private void killServerCursor(final MongoNamespace namespace, final ServerCursor localServerCursor,

driver-core/src/main/com/mongodb/internal/operation/ChangeStreamBatchCursor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public List<T> tryNext() {
9696
return resumeableOperation(commandBatchCursor -> {
9797
try {
9898
List<RawBsonDocument> tryNext = commandBatchCursor.tryNext();
99-
return tryNext == null ? null :
100-
convertAndProduceLastId(tryNext, changeStreamOperation.getDecoder(), lastId -> resumeToken = lastId);
99+
return tryNext == null ? null
100+
: convertAndProduceLastId(tryNext, changeStreamOperation.getDecoder(), lastId -> resumeToken = lastId);
101101
} finally {
102102
cachePostBatchResumeToken(commandBatchCursor);
103103
}

driver-core/src/main/com/mongodb/internal/operation/CommandBatchCursorHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.bson.BsonValue;
3333
import org.bson.FieldNameValidator;
3434

35-
import static com.mongodb.internal.operation.CursorHelper.getNumberToReturn;
3635
import static com.mongodb.internal.operation.DocumentHelper.putIfNotNull;
3736
import static com.mongodb.internal.operation.OperationHelper.LOGGER;
3837
import static com.mongodb.internal.operation.ServerVersionHelper.serverIsAtLeastVersionFourDotFour;

driver-core/src/main/com/mongodb/internal/operation/CursorHelper.java

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,6 @@
2222

2323
final class CursorHelper {
2424

25-
/**
26-
* <p>Gets the limit of the number of documents in the OP_REPLY response to the get more request. A value of zero tells the server to
27-
* use the default size. A negative value tells the server to return no more than that number and immediately close the cursor.
28-
* Otherwise, the server will return no more than that number and return the same cursorId to allow the rest of the documents to be
29-
* fetched, if it turns out there are more documents.</p>
30-
*
31-
* <p>The value returned by this method is based on the limit, the batch size, both of which can be positive, negative, or zero, and the
32-
* number of documents fetched so far.</p>
33-
*
34-
* @return the value for numberToReturn in the OP_GET_MORE wire protocol message.
35-
* @mongodb.driver.manual ../meta-driver/latest/legacy/mongodb-wire-protocol/#op-get-more OP_GET_MORE
36-
* @param limit the user-specified limit on the number of results returned
37-
* @param batchSize the user-specified batch size
38-
* @param numReturnedSoFar the number of results returned so far
39-
*/
40-
static int getNumberToReturn(final int limit, final int batchSize, final int numReturnedSoFar) {
41-
int numberToReturn;
42-
if (Math.abs(limit) != 0) {
43-
numberToReturn = Math.abs(limit) - numReturnedSoFar;
44-
if (batchSize != 0 && numberToReturn > Math.abs(batchSize)) {
45-
numberToReturn = batchSize;
46-
}
47-
} else {
48-
numberToReturn = batchSize;
49-
}
50-
return numberToReturn;
51-
}
52-
5325
static BsonDocument getCursorDocumentFromBatchSize(@Nullable final Integer batchSize) {
5426
return batchSize == null ? new BsonDocument() : new BsonDocument("batchSize", new BsonInt32(batchSize));
5527
}

driver-core/src/test/resources/unified-test-format/command-monitoring/find.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@
390390
},
391391
{
392392
"description": "A successful find event with a getmore and the server kills the cursor (<= 4.4)",
393+
"comment": "UPDATED final batchSize to 3 as batchSize is no longer calculated see: DRIVERS-1448 ",
393394
"runOnRequirements": [
394395
{
395396
"minServerVersion": "3.1",
@@ -483,7 +484,7 @@
483484
]
484485
},
485486
"collection": "test",
486-
"batchSize": 1
487+
"batchSize": 3
487488
},
488489
"commandName": "getMore",
489490
"databaseName": "command-monitoring-tests"

driver-core/src/test/unit/com/mongodb/internal/operation/AsyncCommandBatchCursorSpecification.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class AsyncCommandBatchCursorSpecification extends Specification {
224224
}
225225

226226
then:
227-
if(responseCursorId > 0) {
227+
if (responseCursorId > 0) {
228228
1 * secondConnection.commandAsync(*_) >> {
229229
// `killCursors` command
230230
((SingleResultCallback<?>) it.last()).onResult(null, null)

driver-core/src/test/unit/com/mongodb/internal/operation/CommandBatchCursorSpecification.groovy

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class CommandBatchCursorSpecification extends Specification {
128128
then:
129129
cursor.next() == FIRST_BATCH
130130

131-
then:
131+
then:
132132
initialConnection.getCount() == 0
133133
connectionSource.getCount() == 0
134134

@@ -177,7 +177,7 @@ class CommandBatchCursorSpecification extends Specification {
177177

178178
then:
179179
0 * connectionA._
180-
0 * connectionB._
180+
0 * connectionB._
181181
initialConnection.getCount() == 0
182182
connectionSource.getCount() == 0
183183

@@ -220,7 +220,7 @@ class CommandBatchCursorSpecification extends Specification {
220220
}
221221

222222
then:
223-
if(responseCursorId > 0) {
223+
if (responseCursorId > 0) {
224224
1 * secondConnection.command(*_) >> null
225225
}
226226

@@ -422,11 +422,6 @@ class CommandBatchCursorSpecification extends Specification {
422422
def 'should handle exceptions when killing cursor and a connection can not be obtained'() {
423423
given:
424424
def initialConnection = referenceCountedConnection()
425-
def connection = Mock(Connection) {
426-
_ * getDescription() >> Stub(ConnectionDescription) {
427-
getMaxWireVersion() >> 4
428-
}
429-
}
430425
def connectionSource = Stub(ConnectionSource) {
431426
getConnection() >> { throw new MongoSocketOpenException("can't open socket", SERVER_ADDRESS, new IOException()) }
432427
getServerApi() >> null

driver-core/src/test/unit/com/mongodb/internal/operation/CursorHelperTest.java

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)