Skip to content

Commit 1e830cf

Browse files
author
Oleksandr Poliakov
committed
Fix nullreference exception.
1 parent 4314f4a commit 1e830cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/MongoDB.Driver/MongoCollectionImpl.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,8 @@ public override TProjection FindOneAndUpdate<TProjection>(IClientSessionHandle s
497497
Ensure.IsNotNull(session, nameof(session));
498498
Ensure.IsNotNull(filter, nameof(filter));
499499
Ensure.IsNotNull(update, nameof(update));
500+
501+
options ??= new FindOneAndUpdateOptions<TDocument, TProjection>();
500502
if (update is PipelineUpdateDefinition<TDocument> && (options.ArrayFilters != null && options.ArrayFilters.Any()))
501503
{
502504
throw new NotSupportedException("An arrayfilter is not supported in the pipeline-style update.");
@@ -517,6 +519,7 @@ public override Task<TProjection> FindOneAndUpdateAsync<TProjection>(IClientSess
517519
Ensure.IsNotNull(session, nameof(session));
518520
Ensure.IsNotNull(filter, nameof(filter));
519521
Ensure.IsNotNull(update, nameof(update));
522+
options ??= new FindOneAndUpdateOptions<TDocument, TProjection>();
520523
if (update is PipelineUpdateDefinition<TDocument> && (options.ArrayFilters != null && options.ArrayFilters.Any()))
521524
{
522525
throw new NotSupportedException("An arrayfilter is not supported in the pipeline-style update.");
@@ -1030,7 +1033,6 @@ private FindOneAndUpdateOperation<TProjection> CreateFindOneAndUpdateOperation<T
10301033
UpdateDefinition<TDocument> update,
10311034
FindOneAndUpdateOptions<TDocument, TProjection> options)
10321035
{
1033-
options = options ?? new FindOneAndUpdateOptions<TDocument, TProjection>();
10341036
var renderArgs = GetRenderArgs();
10351037
var projection = options.Projection ?? new ClientSideDeserializationProjectionDefinition<TDocument, TProjection>();
10361038
var renderedProjection = projection.Render(renderArgs with { RenderForFind = true });

0 commit comments

Comments
 (0)