Skip to content

Commit e555c26

Browse files
author
Oleksandr Poliakov
committed
Pr
1 parent 51c7dc8 commit e555c26

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

src/MongoDB.Driver/Core/Misc/Ensure.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,11 @@ public static string IsNullOrNotEmpty(string value, string paramName)
444444
/// <returns>The value of the parameter.</returns>
445445
public static TimeSpan? IsNullOrValidTimeout(TimeSpan? value, string paramName)
446446
{
447-
if (value == null)
447+
if (value != null)
448448
{
449-
return null;
449+
IsValidTimeout(value.Value, paramName);
450450
}
451-
452-
return IsValidTimeout(value.Value, paramName);
451+
return value;
453452
}
454453

455454
/// <summary>

src/MongoDB.Driver/Core/Operations/FindOperation.cs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,33 +250,24 @@ public BsonDocument CreateCommand(OperationContext operationContext, ICoreSessio
250250
}
251251

252252
var isShardRouter = connectionDescription.HelloResult.ServerType == ServerType.ShardRouter;
253-
254-
var effectiveComment = _comment;
255-
var effectiveHint = _hint;
256-
var effectiveMax = _max;
257-
var effectiveMin = _min;
258-
var effectiveReturnKey = _returnKey;
259-
var effectiveShowRecordId = _showRecordId;
260-
var effectiveSort = _sort;
261-
262253
var readConcern = ReadConcernHelper.GetReadConcernForCommand(session, connectionDescription, _readConcern);
263254
return new BsonDocument
264255
{
265256
{ "find", _collectionNamespace.CollectionName },
266257
{ "filter", _filter, _filter != null },
267-
{ "sort", effectiveSort, effectiveSort != null },
258+
{ "sort", _sort, _sort != null },
268259
{ "projection", _projection, _projection != null },
269-
{ "hint", effectiveHint, effectiveHint != null },
260+
{ "hint", _hint, _hint != null },
270261
{ "skip", () => _skip.Value, _skip.HasValue },
271262
{ "limit", () => Math.Abs(_limit.Value), _limit.HasValue && _limit != 0 },
272263
{ "batchSize", () => batchSize.Value, batchSize.HasValue && batchSize > 0 },
273264
{ "singleBatch", () => _limit < 0 || _singleBatch.Value, _limit < 0 || _singleBatch.HasValue },
274-
{ "comment", effectiveComment, effectiveComment != null },
265+
{ "comment", _comment, _comment != null },
275266
{ "maxTimeMS", () => MaxTimeHelper.ToMaxTimeMS(_maxTime.Value), _maxTime.HasValue && !operationContext.IsRootContextTimeoutConfigured() },
276-
{ "max", effectiveMax, effectiveMax != null },
277-
{ "min", effectiveMin, effectiveMin != null },
278-
{ "returnKey", () => effectiveReturnKey.Value, effectiveReturnKey.HasValue },
279-
{ "showRecordId", () => effectiveShowRecordId.Value, effectiveShowRecordId.HasValue },
267+
{ "max", _max, _max != null },
268+
{ "min", _min, _min != null },
269+
{ "returnKey", () => _returnKey.Value, _returnKey.HasValue },
270+
{ "showRecordId", () => _showRecordId.Value, _showRecordId.HasValue },
280271
{ "tailable", true, _cursorType == CursorType.Tailable || _cursorType == CursorType.TailableAwait },
281272
{ "oplogReplay", () => _oplogReplay.Value, _oplogReplay.HasValue },
282273
{ "noCursorTimeout", () => _noCursorTimeout.Value, _noCursorTimeout.HasValue },

src/MongoDB.Driver/Core/WireProtocol/CommandUsingCommandMessageWireProtocol.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private Type0CommandMessageSection<BsonDocument> CreateType0Section(OperationCon
380380
if (serverTimeout != Timeout.InfiniteTimeSpan)
381381
{
382382
serverTimeout -= _roundTripTime;
383-
if (serverTimeout < TimeSpan.Zero)
383+
if (serverTimeout <= TimeSpan.Zero)
384384
{
385385
throw new TimeoutException();
386386
}

0 commit comments

Comments
 (0)