<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 09:02:36 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-4641] Fix how InterruptedExceptions are handled</title>
                <link>https://jira.mongodb.org/browse/JAVA-4641</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Before &lt;a href=&quot;https://openjdk.java.net/jeps/428&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;JEP 428: Structured Concurrency (Incubator)&lt;/a&gt;, the importance of the &lt;a href=&quot;https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Thread.html#interrupt()&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;interrupt mechanism&lt;/a&gt; for the driver was based mostly on the potentiality of user code to use the following pieces of the Java SE API:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/Future.html#cancel(boolean)&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;Future.cancel&lt;/tt&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ExecutorService.html#shutdownNow()&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;tt&gt;ExecutorService.shutdownNow&lt;/tt&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;and on a few occasions when the driver uses this mechanism directly. Structured concurrency adds new functionality that relies on interrupts: &lt;a href=&quot;https://openjdk.java.net/jeps/428#:~:text=Any%20fork%20in,in%20sequential%20code.&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&lt;em&gt;&quot;Any fork in a scope, their own transitive forks, or the scope&apos;s owner, can call StructuredTaskScope.shutdown at any time to signify that the task is complete, even while other forks are still running. shutdown causes the threads of all forks that are still active in the scope to be interrupted; all forks should, therefore, be written in a way that is responsive to interruption. In effect, shutdown is the concurrent analog of the break statement in sequential code.&quot;&lt;/em&gt;&lt;/a&gt;. This gives us one more reason to make sure the driver code is responsive to interruption.&lt;/p&gt;

&lt;p&gt;We discussed this with &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=jeff.yemin%40mongodb.com&quot; class=&quot;user-hover&quot; rel=&quot;jeff.yemin@mongodb.com&quot;&gt;jeff.yemin@mongodb.com&lt;/a&gt;, and so far the agreement is that we need to make sure driver&apos;s code satisfies the following set of rules:&lt;/p&gt;

&lt;ol&gt;
	&lt;li&gt;If a method throws &lt;tt&gt;InterruptedException&lt;/tt&gt; (this implies it is declared as throwing &lt;tt&gt;Throwable&lt;/tt&gt;/&lt;tt&gt;Exception&lt;/tt&gt;/&lt;tt&gt;InterruptedException&lt;/tt&gt;), then the &lt;a href=&quot;https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Thread.html#isInterrupted()&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;interrupted flag&lt;/a&gt; must not be raised by the driver.&lt;/li&gt;
	&lt;li&gt;If a synchronous method prohibits an &lt;tt&gt;InterruptedException&lt;/tt&gt; from being propagated through the call stack, for example, by throwing another exception instead (even if it is &lt;tt&gt;MongoInterruptedException&lt;/tt&gt;), then the flag must be raised by the driver, unless
	&lt;ol&gt;
		&lt;li&gt;this is a &lt;tt&gt;Thread.run&lt;/tt&gt; method, or a similar method acting as the bottom/end of a call stack;&lt;/li&gt;
		&lt;li&gt;this is an thread managed by the driver, in which case the driver is free to handle interrupts differently, as it cannot surprise the user code, unless this thread may execute user code and the driver documented guarantees regarding threads that may execute it and how they react to interrupts (currently, we don&apos;t expose such guarantees).&lt;/li&gt;
	&lt;/ol&gt;
	&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;These rules mean, for example, that in situations when we catch &lt;tt&gt;Throwable&lt;/tt&gt;/&lt;tt&gt;Exception&lt;/tt&gt; in synchronous code and do not re-throw it as is, we must catch &lt;tt&gt;InterruptedException&lt;/tt&gt; separately and then either throw it as is, or raise the flag. In asynchronous code, when we catch &lt;tt&gt;Throwable&lt;/tt&gt;/&lt;tt&gt;Exception&lt;/tt&gt; only to propagate it to a callback because exceptions in asynchronous code are not propagated through the call stack, we must not treat &lt;tt&gt;InterruptedException&lt;/tt&gt; specially.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2066367">JAVA-4641</key>
            <summary>Fix how InterruptedExceptions are handled</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="9">Done</resolution>
                                        <assignee username="valentin.kovalenko@mongodb.com">Valentin Kavalenka</assignee>
                                    <reporter username="valentin.kovalenko@mongodb.com">Valentin Kavalenka</reporter>
                        <labels>
                            <label>loom</label>
                    </labels>
                <created>Fri, 10 Jun 2022 22:10:40 +0000</created>
                <updated>Tue, 12 Sep 2023 04:58:04 +0000</updated>
                            <resolved>Tue, 12 Sep 2023 04:58:04 +0000</resolved>
                                                    <fixVersion>4.11.0</fixVersion>
                                    <component>Internal</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                <comments>
                            <comment id="5696495" author="xgen-internal-githook" created="Tue, 12 Sep 2023 04:56:54 +0000"  >&lt;p&gt;Author: &lt;/p&gt;
{&apos;name&apos;: &apos;Valentin Kovalenko&apos;, &apos;email&apos;: &apos;valentin.kovalenko@mongodb.com&apos;, &apos;username&apos;: &apos;stIncMale&apos;}
&lt;p&gt;Message: Fix how `InterruptedException`s are handled (#1192)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-4641&quot; title=&quot;Fix how InterruptedExceptions are handled&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-4641&quot;&gt;&lt;del&gt;JAVA-4641&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/4f5417fd94bc666ce4638042a26a2807a42137e1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/4f5417fd94bc666ce4638042a26a2807a42137e1&lt;/a&gt;&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="10038"><![CDATA[Fully Compatible]]></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_10257" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Documentation Changes</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="11861"><![CDATA[Not Needed]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_14266" key="com.atlassian.jira.plugin.system.customfieldtypes:textarea">
                        <customfieldname>Documentation Changes Summary</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>&lt;p&gt;1.  What would you like to communicate to the user about this feature?&lt;br/&gt;
2.  Would you like the user to see examples of the syntax and/or executable code and its output?&lt;br/&gt;
3.  Which versions of the driver/connector does this apply to?&lt;/p&gt;</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>JAVA-4649</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_21553" key="com.atlassian.jira.plugin.system.customfieldtypes:labels">
                        <customfieldname>Quarter</customfieldname>
                        <customfieldvalues>
                                        <label>FY24Q3</label>
    
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr1d6w:r9</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>