<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:59:13 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-3279] distinct on using non-sparse index throws NPE</title>
                <link>https://jira.mongodb.org/browse/JAVA-3279</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Calling `.distinct` on a collection with a non-sparse index on a field, that is missing from at least one document, results in a NullPointerException. The reason is that due to the index not being sparse, null is added to the distinct values for the missing field. `AbstractSubscription` checks if the entire returned array is null (which it isn&apos;t), but not the individual elements. `resultsQueue.addAll(results)` then fails with an NPE.&lt;/p&gt;

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

&lt;p&gt;```scala&lt;br/&gt;
val db = client.getDatabase(&quot;foo&quot;)&lt;br/&gt;
val coll = db.getCollection&lt;span class=&quot;error&quot;&gt;&amp;#91;Document&amp;#93;&lt;/span&gt;(&quot;bar&quot;)&lt;br/&gt;
for &lt;/p&gt;
{
  _ &amp;lt;- coll.createIndex(ascending(&quot;a&quot;)).toFuture()
  _ &amp;lt;- coll.insertOne(Document(&quot;b&quot; -&amp;gt; 1)).toFuture()
  dist &amp;lt;- coll.distinct[String](&quot;a&quot;).toFuture()
}
&lt;p&gt; yield dist should contain theSameElementsAs Seq(null)&lt;br/&gt;
```&lt;/p&gt;

&lt;p&gt;```&lt;br/&gt;
 10:27:42.110 &lt;span class=&quot;error&quot;&gt;&amp;#91;zio-default-async-6-352707738&amp;#93;&lt;/span&gt; DEBUG o.m.d.p.command - Sending command &apos;{&quot;distinct&quot;: &quot;bar&quot;, &quot;key&quot;: &quot;a&quot;, &quot;$db&quot;: &quot;foo&quot;, &quot;$readPreference&quot;: {&quot;mode&quot;: &quot;primaryPreferred&quot;}}&apos; with request id 10 to database foo on connection [connectionId&lt;/p&gt;
{localValue:2, serverValue:2}
&lt;p&gt;] to server localhost:12345&lt;br/&gt;
10:27:42.111 &lt;span class=&quot;error&quot;&gt;&amp;#91;Thread-20&amp;#93;&lt;/span&gt; DEBUG o.m.d.p.command - Execution of command with request id 10 completed successfully in 1.78 ms on connection [connectionId&lt;/p&gt;
{localValue:2, serverValue:2}
&lt;p&gt;] to server localhost:12345&lt;br/&gt;
10:27:42.115 &lt;span class=&quot;error&quot;&gt;&amp;#91;Thread-20&amp;#93;&lt;/span&gt; ERROR o.m.d.client - Callback onResult call produced an error&lt;br/&gt;
java.lang.NullPointerException: null&lt;br/&gt;
	at java.util.concurrent.ConcurrentLinkedQueue.checkNotNull(ConcurrentLinkedQueue.java:920)&lt;br/&gt;
	at java.util.concurrent.ConcurrentLinkedQueue.addAll(ConcurrentLinkedQueue.java:531)&lt;br/&gt;
	at com.mongodb.async.client.AbstractSubscription.addToQueue(AbstractSubscription.java:116)&lt;br/&gt;
	at com.mongodb.async.client.MongoIterableSubscription$2.onResult(MongoIterableSubscription.java:95)&lt;br/&gt;
	at com.mongodb.async.client.MongoIterableSubscription$2.onResult(MongoIterableSubscription.java:85)&lt;br/&gt;
...&lt;br/&gt;
```&lt;/p&gt;</description>
                <environment>mongo-scala-driver 2.6.0&lt;br/&gt;
mongoDB 4.0</environment>
        <key id="744212">JAVA-3279</key>
            <summary>distinct on using non-sparse index throws NPE</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="john.stewart@mongodb.com">John Stewart</assignee>
                                    <reporter username="simon.schenk@risk42.com">Simon Schenk</reporter>
                        <labels>
                    </labels>
                <created>Wed, 24 Apr 2019 09:53:20 +0000</created>
                <updated>Sat, 28 Oct 2023 11:22:15 +0000</updated>
                            <resolved>Tue, 6 Aug 2019 15:44:00 +0000</resolved>
                                                    <fixVersion>3.11.0</fixVersion>
                                    <component>Async</component>
                    <component>Query Operations</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="2359708" author="xgen-internal-githook" created="Tue, 6 Aug 2019 15:43:40 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;John Stewart&apos;, &apos;email&apos;: &apos;john.stewart@mongodb.com&apos;, &apos;username&apos;: &apos;jstewart-mongo&apos;}
&lt;p&gt;Message: Handle null results for reactive applications&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-3279&quot; title=&quot;distinct on using non-sparse index throws NPE&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-3279&quot;&gt;&lt;del&gt;JAVA-3279&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/cc1be4d952467687e6db9b8c1e5e04187d95769d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/cc1be4d952467687e6db9b8c1e5e04187d95769d&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="2227557" author="ian@10gen.com" created="Mon, 29 Apr 2019 14:18:52 +0000"  >&lt;p&gt;Hey &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=sschenk&quot; class=&quot;user-hover&quot; rel=&quot;sschenk&quot;&gt;sschenk&lt;/a&gt; moving this from SCALA to JAVA because the bug is actually inside of the Java driver code.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="894523">JAVA-3382</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </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|hr6u3r:</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>