Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2227

NullReferenceException when setting int[] to NULL

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5
    • Component/s: Serialization
    • Labels:
      None
    • Environment:
      Windows Server 2016 / 10

      Assigning null to int[] property on data entity,
      causing exception in the driver code,

      System.NullReferenceException: Object reference not set to an instance of an object.
      at MongoDB.Driver.FieldValueSerializerHelper.ConvertIfPossibleSerializer2.TryConvertValue(TFrom value, TTo& convertedValue)
      at MongoDB.Driver.FieldValueSerializerHelper.ConvertIfPossibleSerializer2.Serialize(BsonSerializationContext context, BsonSerializationArgs args, TFrom value
      at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Serialize[TValue](IBsonSerializer1 serializer, BsonSerializationContext context, TValue value)
      at MongoDB.Driver.OperatorUpdateDefinition2.Render(IBsonSerializer1 documentSerializer, IBsonSerializerRegistry serializerRegistry)
      at MongoDB.Driver.CombinedUpdateDefinition1.Render(IBsonSerializer1 documentSerializer, IBsonSerializerRegistry serializerRegistry)
      at MongoDB.Driver.MongoCollectionImpl1.ConvertWriteModelToWriteRequest(WriteModel1 model, Int32 index)
      at System.Linq.Enumerable.<SelectIterator>d__52.MoveNext()
      at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
      at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
      at MongoDB.Driver.Core.Operations.BulkMixedWriteOperation..ctor(CollectionNamespace collectionNamespace, IEnumerable1 requests, MessageEncoderSettings messageEncoderSettings)
      at MongoDB.Driver.MongoCollectionImpl1.CreateBulkWriteOperation(IEnumerable1 requests, BulkWriteOptions options)
      at MongoDB.Driver.MongoCollectionImpl1.<BulkWriteAsync>d__26.MoveNext()
      -- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
      at MongoDB.Driver.MongoCollectionImpl1.d__911.MoveNext()
      -- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
      at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
      at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
      at MongoDB.Driver.MongoCollectionBase1.d__93.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
      at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
      

      see my comment here,

      https://github.com/mongodb/mongo-csharp-driver/commit/8fe8e0a2696a4255f0567a25842223d7be42ca27#diff-bf7ce5c4325e843b46a8496e92a71805

            Assignee:
            Unassigned Unassigned
            Reporter:
            artem@jellybtn.com Artem Meron
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: