<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:35:48 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[CSHARP-98] Deserialization Fails on 2nd object read</title>
                <link>https://jira.mongodb.org/browse/CSHARP-98</link>
                <project id="10041" key="CSHARP">C# Driver</project>
                    <description>&lt;p&gt;Sometime between 11/5 and now this broke. Did a pull and got the latest code now the deserialization is broken.&lt;/p&gt;

&lt;p&gt;Steps to reproduce:&lt;/p&gt;

&lt;p&gt;1. Create two classes, one that derives from another. (ie class B: A)&lt;br/&gt;
2. Set up mapping through attributes, or just use default. &lt;br/&gt;
3. Create two instances of B and save to a collection.&lt;br/&gt;
4. Query the collection specifying the custom type db.GetCollection&amp;lt;A&amp;gt;(&quot;myCollection&quot;).Find(...)   (make sure this query returns at least 2 documents of type B).&lt;/p&gt;

&lt;p&gt;This fails at the deserialization stage on the 2nd type B document.&lt;/p&gt;

&lt;p&gt;Seems to be an issue with the bsonReader&apos;s buffer index not getting updated properly b/c it is set to EndOfDocument when it tries to deserialize the 2nd document causing a the actualType to default to the nominalType and therefore causes failure when deserializing. I stepped through the code a bit and this is the beginning of where everything goes bad:&lt;/p&gt;

&lt;p&gt;// BsonClassMapSerializer.cs line 57&lt;br/&gt;
var actualType = discriminatorConvention.GetActualType(bsonReader, nominalType);&lt;/p&gt;

&lt;p&gt;The actualType comes back the same as the nominalType (A) when it should come back as B. Since the data stored in the db is of type B, the properties cant get set and an exception gets thrown.&lt;/p&gt;




&lt;p&gt;Stack Trace:&lt;/p&gt;

&lt;p&gt;at MongoDB.Bson.DefaultSerializer.BsonClassMapSerializer.Deserialize(BsonReader bsonReader, Type nominalType) in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Bson\DefaultSerializer\BsonClassMapSerializer.cs:line 91&lt;br/&gt;
   at MongoDB.Bson.Serialization.BsonSerializer.Deserialize(BsonReader bsonReader, Type nominalType) in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Bson\Serialization\BsonSerializer.cs:line 70&lt;br/&gt;
   at MongoDB.Bson.Serialization.BsonSerializer.Deserialize&lt;span class=&quot;error&quot;&gt;&amp;#91;T&amp;#93;&lt;/span&gt;(BsonReader bsonReader) in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Bson\Serialization\BsonSerializer.cs:line 46&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoReplyMessage`1.ReadFrom(BsonBuffer buffer) in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Driver\Internal\MongoReplyMessage.cs:line 88&lt;br/&gt;
   at MongoDB.Driver.Internal.MongoConnection.ReceiveMessage&lt;span class=&quot;error&quot;&gt;&amp;#91;TDocument&amp;#93;&lt;/span&gt;() in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 291&lt;br/&gt;
   at MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetReply(MongoRequestMessage message) in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Driver\Core\MongoCursor.cs:line 487&lt;br/&gt;
   at MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.GetFirst() in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Driver\Core\MongoCursor.cs:line 452&lt;br/&gt;
   at MongoDB.Driver.MongoCursor`2.MongoCursorEnumerator.MoveNext() in C:\DEVELOPMENT\trunk\Beast\mongo-csharp-driver\Driver\Core\MongoCursor.cs:line 369&lt;br/&gt;
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)&lt;/p&gt;</description>
                <environment>Win XP. .NET 3.5</environment>
        <key id="13694">CSHARP-98</key>
            <summary>Deserialization Fails on 2nd object read</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="robert@mongodb.com">Robert Stam</assignee>
                                    <reporter username="sym3tri">Ed Rooth</reporter>
                        <labels>
                    </labels>
                <created>Mon, 15 Nov 2010 06:43:15 +0000</created>
                <updated>Thu, 2 Apr 2015 18:27:46 +0000</updated>
                            <resolved>Mon, 15 Nov 2010 20:54:00 +0000</resolved>
                                                    <fixVersion>0.9</fixVersion>
                                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="20331" author="rstam" created="Mon, 15 Nov 2010 20:54:00 +0000"  >&lt;p&gt;Thanks for the detailed information in the bug report. Made it really easy to reproduce and fix.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10012"><![CDATA[Major Change]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrh9pb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14371</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>