<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 09:02:18 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-4524] Observable.map calls onComplete after onError</title>
                <link>https://jira.mongodb.org/browse/JAVA-4524</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;h4&gt;&lt;a name=&quot;Summary&quot;&gt;&lt;/a&gt;Summary&lt;/h4&gt;

&lt;p&gt;Driver version: 4.5.0&lt;/p&gt;

&lt;p&gt;Following up from&#160;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-4304&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;JAVA-4304&lt;/a&gt;,&#160;it seems that Observable.map does not take into account whether the inner function threw an exception when calling onComplete.&lt;/p&gt;

&lt;p&gt;So, when an exception occurs, MapObservable first calls onError (which is fine) and then onComplete on the the next Observer in the chain, which is against the reactive streams spec.&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;HowtoReproduce&quot;&gt;&lt;/a&gt;How to Reproduce&lt;/h4&gt;

&lt;p&gt;The following code will throw an IllegalStateException in ToSingleObservablePublisher with message &quot;onComplete called after the Observer has already completed or errored.&quot;&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;val future = SingleObservable&lt;span class=&quot;error&quot;&gt;&amp;#91;Int&amp;#93;&lt;/span&gt;(1).map( { x =&amp;gt;&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;&#160; throw new RuntimeException(&quot;Some exception&quot;)&lt;/tt&gt;&lt;br/&gt;
&lt;tt&gt;} ).toSingle().toFuture()&lt;/tt&gt;&lt;/p&gt;
&lt;h4&gt;&lt;a name=&quot;AdditionalBackground&quot;&gt;&lt;/a&gt;Additional Background&lt;/h4&gt;

&lt;p&gt;I&apos;ve managed to circumvent the bug by making a patched version of the Observable.map method that simply does not call onComplete after an exception has occured in the inner function. My code is really bad and Scala 3, though, so sharing it won&apos;t help much. &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/biggrin.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&#160;But the fix seems easy enough.&lt;/p&gt;</description>
                <environment></environment>
        <key id="1997480">JAVA-4524</key>
            <summary>Observable.map calls onComplete after onError</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="10300" iconUrl="https://jira.mongodb.org/images/icons/priorities/medium.svg">Unknown</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="3">Duplicate</resolution>
                                        <assignee username="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="ostrzycielnozyczek@gmail.com">Ostrzyciel No&#380;yczek</reporter>
                        <labels>
                            <label>external-user</label>
                    </labels>
                <created>Wed, 9 Mar 2022 09:40:09 +0000</created>
                <updated>Wed, 4 May 2022 13:15:04 +0000</updated>
                            <resolved>Wed, 16 Mar 2022 10:50:25 +0000</resolved>
                                    <version>4.5.0</version>
                                                    <component>Scala</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="4415097" author="JIRAUSER1265419" created="Wed, 16 Mar 2022 10:56:29 +0000"  >&lt;p&gt;Thanks for investigating this! &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;</comment>
                            <comment id="4415084" author="ross@10gen.com" created="Wed, 16 Mar 2022 10:50:25 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ostrzycielnozyczek%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;ostrzycielnozyczek@gmail.com&quot;&gt;ostrzycielnozyczek@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;After testing, I can confirm this was fixed by &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-4487&quot; title=&quot;Use project reactor for Scala Observable implicits&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-4487&quot;&gt;&lt;del&gt;JAVA-4487&lt;/del&gt;&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                            <comment id="4413471" author="ross@10gen.com" created="Tue, 15 Mar 2022 17:22:00 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ostrzycielnozyczek%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;ostrzycielnozyczek@gmail.com&quot;&gt;ostrzycielnozyczek@gmail.com&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;According to the reactive streams spec 2.13, throwing an error from onNext is not allowed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Calling onSubscribe, onNext, onError or onComplete MUST return normally except when any provided parameter is null in which case it MUST throw a java.lang.NullPointerException to the caller, for all other situations the only legal way for a Subscriber to signal failure is by cancelling its Subscription. In the case that this rule is violated, any associated Subscription to the Subscriber MUST be considered as cancelled, and the caller MUST raise this error condition in a fashion that is adequate for the runtime environment.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;However, I will add a further check to ensure onComplete isn&apos;t called - as that is definitely a bug in the mapping observable and I&apos;ll ensure that the error is propagated correctly.&lt;/p&gt;

&lt;p&gt;Ross&lt;/p&gt;</comment>
                            <comment id="4407612" author="esha.bhargava" created="Fri, 11 Mar 2022 20:58:14 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=ostrzycielnozyczek%40gmail.com&quot; class=&quot;user-hover&quot; rel=&quot;ostrzycielnozyczek@gmail.com&quot;&gt;ostrzycielnozyczek@gmail.com&lt;/a&gt; Thank you for reporting this issue! We&apos;ll look into it and get back to you soon.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="1876006">JAVA-4304</issuekey>
        </issuelink>
                            </outwardlinks>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1980112">JAVA-4487</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </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|i04z4r:r</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>