<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 09:00:46 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>[JAVA-3916] Driver decodes BsonInt64 as Integer</title>
                <link>https://jira.mongodb.org/browse/JAVA-3916</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Driver fails to read `BsonInt64` as Long and results in ClassCastException:&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;Minimal reproducible example:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://gist.github.com/aaabramov/89625595893d0ff513d1512b43a21caa&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/aaabramov/89625595893d0ff513d1512b43a21caa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;What happens here is that driver reads `field` as an `Integer` and puts it into `org.bson.Document#documentAsMap` then tries to class it as a `Long` in `org.bson.Document#getLong`.&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;And the interesting thing is we&apos;ll try to persist `coll.insertOne(Document(&quot;field&quot; -&amp;gt; BsonInt64(Long.MaxValue))).toFuture()` everything would work just fine. So seems that driver chooses resulting type based on its value?&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;It was working fine with driver `&quot;org.mongodb.scala&quot; %% &quot;mongo-scala-driver&quot; % &quot;2.7.0&quot;`&lt;/p&gt;

&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;&lt;span class=&quot;image-wrap&quot; style=&quot;&quot;&gt;&lt;img src=&quot;https://jira.mongodb.org/secure/attachment/292629/292629_image-2020-12-21-12-19-31-381.png&quot; style=&quot;border: 0px solid black&quot; /&gt;&lt;/span&gt;&lt;/p&gt;</description>
                <environment>```&lt;br/&gt;
docker run --rm -p 27017:27017 mongo:4.4.2&lt;br/&gt;
docker run --rm -p 27017:27017 nikore/mongo:4.0-v2&lt;br/&gt;
```&lt;br/&gt;
&lt;br/&gt;
```&lt;br/&gt;
openjdk version &amp;quot;1.8.0_265&amp;quot;&lt;br/&gt;
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)&lt;br/&gt;
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.265-b01, mixed mode)&lt;br/&gt;
```&lt;br/&gt;
&lt;br/&gt;
```&lt;br/&gt;
Darwin MBP15-9814af 18.7.0 Darwin Kernel Version 18.7.0: Tue Nov 10 00:07:31 PST 2020; root:xnu-4903.278.51~1/RELEASE_X86_64 x86_64&lt;br/&gt;
```&lt;br/&gt;
&lt;br/&gt;
```&lt;br/&gt;
scalaVersion 2.12.12&lt;br/&gt;
sbt 1.4.5&lt;br/&gt;
```&lt;br/&gt;
</environment>
        <key id="1575447">JAVA-3916</key>
            <summary>Driver decodes BsonInt64 as Integer</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="13201">Fixed</resolution>
                                        <assignee username="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="aabrasha@gmail.com">Andrii Abramov</reporter>
                        <labels>
                    </labels>
                <created>Mon, 21 Dec 2020 10:30:41 +0000</created>
                <updated>Sat, 28 Oct 2023 11:21:31 +0000</updated>
                            <resolved>Wed, 13 Jan 2021 14:56:25 +0000</resolved>
                                    <version>4.1.0</version>
                                    <fixVersion>4.2.0</fixVersion>
                                    <component>Scala</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="3562461" author="xgen-internal-githook" created="Wed, 13 Jan 2021 14:54:07 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ross Lawley&apos;, &apos;email&apos;: &apos;ross.lawley@gmail.com&apos;, &apos;username&apos;: &apos;rozza&apos;}
&lt;p&gt;Message: Scala: Ensure implicit conversion keeps type fidelity (#627)&lt;/p&gt;

&lt;p&gt;When converting from a BsonDocument to org.bson.Document&lt;br/&gt;
the scala driver previously used json. The implementation&lt;br/&gt;
should not rely on the json output format, but rather use&lt;br/&gt;
the Codecs to do the conversion.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-3916&quot; title=&quot;Driver decodes BsonInt64 as Integer&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-3916&quot;&gt;&lt;del&gt;JAVA-3916&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/36d0e7fcf8b8d90ca1a739caaaa53dfb69cad724&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/36d0e7fcf8b8d90ca1a739caaaa53dfb69cad724&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3557835" author="ross@10gen.com" created="Mon, 11 Jan 2021 16:22:29 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/pull/627&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/pull/627&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3538230" author="jeff.yemin" created="Mon, 21 Dec 2020 14:27:31 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=aabrasha%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;aabrasha@gmail.com&quot;&gt;aabrasha@gmail.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for the bug report.  We&apos;ll have a look soon and get back to you.&lt;/p&gt;

&lt;p&gt;Thanks,&lt;br/&gt;
Jeff&lt;/p&gt;</comment>
                            <comment id="3538026" author="JIRAUSER1258056" created="Mon, 21 Dec 2020 11:56:15 +0000"  >&lt;p&gt;Seems that type is lost during implicit conversion between scala &amp;amp; java `Document` in `org.mongodb.scala#documentToUntypedDocument`.&lt;/p&gt;

&lt;p&gt;It is implemented with ScalaDocument=&amp;gt;JSON=&amp;gt;JavaDocument conversion and JsonReader decides whether to pick Long or Integer.&lt;/p&gt;


&lt;p&gt;I would expect the driver to return strict type as it was before.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="292629" name="image-2020-12-21-12-19-31-381.png" size="31914" author="aabrasha@gmail.com" created="Mon, 21 Dec 2020 10:19:32 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <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|hy8ufz:</customfieldvalue>

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