<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 09:02:14 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-4496] Refactor usages of ReferenceCounted such that the retain method is used in a consistent manner</title>
                <link>https://jira.mongodb.org/browse/JAVA-4496</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;&lt;tt&gt;ReferenceCounted.retain&lt;/tt&gt; is supposed to be called each time we store a new reference to a &lt;tt&gt;ReferenceCounted&lt;/tt&gt; object in the process heap. However, for various reasons, including the fact that manual reference counting is difficult, we sometimes&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/44cf9a4979b69f20d30f5eb80b58356f205cdf5c/driver-core/src/main/com/mongodb/internal/connection/DefaultServer.java#L396&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Omit calling &lt;tt&gt;ReferenceCounted.retain&lt;/tt&gt;&lt;/a&gt; because at the moment of writing the new code we have knowledge non-local to the current method/constructor that allows us to do so. However, this means that reading/changing such code later will require the same knowledge that cannot be acquired by studying the code locally. This is especially confusing in situations when we &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/44cf9a4979b69f20d30f5eb80b58356f205cdf5c/driver-sync/src/main/com/mongodb/client/internal/ClientSessionBinding.java#L150-L151&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;store two references in heap, but call &lt;tt&gt;retain&lt;/tt&gt; only for one of them&lt;/a&gt;.&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/blob/44cf9a4979b69f20d30f5eb80b58356f205cdf5c/driver-core/src/main/com/mongodb/internal/operation/AsyncQueryBatchCursor.java#L231&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Call &lt;tt&gt;ReferenceCounted.retain&lt;/tt&gt; too early in the code, outside of the method/constructor that actually stores a new reference in the heap&lt;/a&gt;.  Doing so also requires non-local knowledge when reading/changing the code.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;As a result, it is very difficult (at least to me, but maybe I am not the only one) to reason about the code that uses reference counting. To improve the matters, we could&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;refactor all existing usages of &lt;tt&gt;ReferenceCounted&lt;/tt&gt; such that &lt;tt&gt;retain&lt;/tt&gt; is always called immediately before (in the &lt;a href=&quot;https://docs.oracle.com/javase/specs/jls/se17/html/jls-17.html#jls-17.4.3&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;program order&lt;/a&gt;) the write action that stores a new reference in the process heap;&lt;/li&gt;
	&lt;li&gt;urge ourselves to follow the approach taken in the aforementioned refactoring.&lt;/li&gt;
&lt;/ul&gt;
</description>
                <environment></environment>
        <key id="1984380">JAVA-4496</key>
            <summary>Refactor usages of ReferenceCounted such that the retain method is used in a consistent manner</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</priority>
                        <status id="10038" iconUrl="https://jira.mongodb.org/images/icons/subtask.gif" description="">Backlog</status>
                    <statusCategory id="2" key="new" colorName="default"/>
                                    <resolution id="-1">Unresolved</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="valentin.kovalenko@mongodb.com">Valentin Kavalenka</reporter>
                        <labels>
                            <label>tech-debt</label>
                    </labels>
                <created>Wed, 16 Feb 2022 01:44:22 +0000</created>
                <updated>Thu, 14 Sep 2023 20:57:31 +0000</updated>
                                                                            <component>Internal</component>
                                        <votes>0</votes>
                                    <watches>1</watches>
                                                                                                                    <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="1606932">JAVA-3978</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|hr3mnb:i</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>