<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 09:03:21 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-4944] Consider refactoring the public API such that we don&apos;t do IO in constructors and constructor methods</title>
                <link>https://jira.mongodb.org/browse/JAVA-4944</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;This ticket was created as a result of &lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/pull/1104#discussion_r1160728842&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/pull/1104#discussion_r1160728842&lt;/a&gt;. The linked discussion has my detailed initial thoughts on the issue.&lt;/p&gt;

&lt;p&gt;In short, doing IO in constructors / constructor methods is usually a bad idea:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;The usual and reasonable expectation of a programmer is that creating an object just creates the object, and does not result in downloading anything from the Internet or launching missiles. I.e., people don&apos;t usually guard object creation with retry logic in case it fails. This leads to the next item.&lt;/li&gt;
	&lt;li&gt;As &lt;a href=&quot;https://github.com/mongodb/specifications/blob/e1828624c79943b5a9b77d7d23af6c69c29e1a5e/source/server-discovery-and-monitoring/server-discovery-and-monitoring-summary.rst#client-construction&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mentioned in the SDAM spec&lt;/a&gt;, if a constructor does network IO, like our &lt;tt&gt;ConnectionString&lt;/tt&gt; or &lt;tt&gt;MongoClients.create&lt;/tt&gt;, then this may result in failing to restart an application when there networking issues, even if the application was working just fine despite those issues.&lt;/li&gt;
	&lt;li&gt;Constructors are synchronous, which means that the IO they do as part of constructing an object must be done synchronously.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;If we explore this and decide to change our API, we at first must deprecate the existing API in 4.x.&lt;/p&gt;

&lt;p&gt;P.S. I discovered that while the &lt;a href=&quot;https://github.com/mongodb/specifications/blob/e1828624c79943b5a9b77d7d23af6c69c29e1a5e/source/server-discovery-and-monitoring/server-discovery-and-monitoring-summary.rst#client-construction&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;SDAM summary&lt;/a&gt; forbids doing any IO when constructing a client, &lt;a href=&quot;https://github.com/mongodb/specifications/blob/e1828624c79943b5a9b77d7d23af6c69c29e1a5e/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#client-construction&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;SDAM&lt;/a&gt; makes an exception for initial DNS seed list discovery when given a connection string with mongodb+srv scheme. This is surprising, and I can&apos;t think of a good justification on my own, but even more surprising is that given this exception, neither document makes an exception for the hostname resolution into an IP address, which is also potentially an IO operation (not necessarily network IO). Regardless of this SDAM exception, doing IO when constructing &lt;tt&gt;ConnectionString&lt;/tt&gt; lead us to the unfortunate API that burdens a user with making sure that the &lt;tt&gt;DnsClient&lt;/tt&gt; set via &lt;tt&gt;MongoClientSettings&lt;/tt&gt; must be the same as the one passed to the &lt;tt&gt;ConnectionString&lt;/tt&gt; constructor.&lt;/p&gt;</description>
                <environment></environment>
        <key id="2317589">JAVA-4944</key>
            <summary>Consider refactoring the public API such that we don&apos;t do IO in constructors and constructor methods</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="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="13202">Works as Designed</resolution>
                                        <assignee username="-1">Unassigned</assignee>
                                    <reporter username="valentin.kovalenko@mongodb.com">Valentin Kavalenka</reporter>
                        <labels>
                    </labels>
                <created>Tue, 18 Apr 2023 16:36:15 +0000</created>
                <updated>Fri, 27 Oct 2023 13:20:51 +0000</updated>
                            <resolved>Wed, 6 Sep 2023 16:02:58 +0000</resolved>
                                                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="5595739" author="jeff.yemin" created="Thu, 27 Jul 2023 15:21:58 +0000"  >&lt;p&gt;I think we would have to deprecate and remove the &lt;tt&gt;applyConnectionString&lt;/tt&gt; methods in the settings builder classes and add methods to MongoClients like:&lt;/p&gt;

&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   MongoClient create(MongoClientSettings settings, String connectionString);  &lt;/span&gt;&lt;span style=&quot;color: #008200; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// apply connection string on top of settings, asynchronously after fetching TXT record&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;   MongoClient create(String connectionString, MongoClientSettings settings);  &lt;/span&gt;&lt;span style=&quot;color: #008200; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;// apply settings on to of connection string, asynchronously after fetching TXT record&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;

&lt;p&gt;I&apos;m not sure the benefit is worth the disruption this would cause for users.&lt;/p&gt;</comment>
                    </comments>
                    <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_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_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr1d6w:rv</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>