<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:57:44 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-2641] Add JSR-305-compatible NonNull annotations to the driver API</title>
                <link>https://jira.mongodb.org/browse/JAVA-2641</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;Annotating the public API with NonNull annotations will allow tools like IntelliJ and other JVM languages like Kotlin to enforce constraints on application code that uses the driver.&lt;/p&gt;

&lt;p&gt;See for an example the recent support for null-safety added to Spring Framework 5.0 &lt;a href=&quot;https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A couple of strange things about JSR-305 that need to be considered:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;It was never actually approved and incorporated into the JDK.  Rather, it&apos;s available at the following Maven coordinates: com.google.code.findbugs:jsr305:3.0.2&lt;/li&gt;
	&lt;li&gt;The package &lt;tt&gt;javax.annotation&lt;/tt&gt; is exported by the &lt;tt&gt;java.xml.ws.annotation&lt;/tt&gt; module in Java 9, and, though it&apos;s deprecated and slated for removal, I think that will conflict with any other module that also contains classes in the same package (like the JSR-305 one).  However, this doesn&apos;t appear to affect Spring, perhaps because the JSR-305 jar file is a &lt;tt&gt;compileOnly&lt;/tt&gt; dependency.&lt;/li&gt;
&lt;/ul&gt;

</description>
                <environment></environment>
        <key id="447326">JAVA-2641</key>
            <summary>Add JSR-305-compatible NonNull annotations to the driver API</summary>
                <type id="2" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14711&amp;avatarType=issuetype">New Feature</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</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="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="jeff.yemin@mongodb.com">Jeffrey Yemin</reporter>
                        <labels>
                    </labels>
                <created>Wed, 18 Oct 2017 14:23:30 +0000</created>
                <updated>Sun, 29 Oct 2023 02:32:32 +0000</updated>
                            <resolved>Tue, 20 Mar 2018 11:52:36 +0000</resolved>
                                                    <fixVersion>3.7.0</fixVersion>
                                    <component>API</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1839703" author="xgen-internal-githook" created="Tue, 20 Mar 2018 15:51:30 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;ross.lawley@gmail.com&apos;, &apos;name&apos;: &apos;Ross Lawley&apos;, &apos;username&apos;: &apos;rozza&apos;}
&lt;p&gt;Message: Moved JSR-305 compatible annotation to driver-core&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&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/8e9a543c10f24b8881a9cac048fe60d1bc762cbc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/8e9a543c10f24b8881a9cac048fe60d1bc762cbc&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1839365" author="xgen-internal-githook" created="Tue, 20 Mar 2018 11:52:26 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Add missing @Nullable annotation to UpdateResult#getUpsertedId&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/2b12bbea2b670cf7db742b529fbc47da0314dccd&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/2b12bbea2b670cf7db742b529fbc47da0314dccd&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1839364" author="xgen-internal-githook" created="Tue, 20 Mar 2018 11:52:25 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Change jsr305 dependendency from optional to compileOnly&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/1139899d6738b21633da878d93edb8d75774f25b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/1139899d6738b21633da878d93edb8d75774f25b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1838542" author="xgen-internal-githook" created="Mon, 19 Mar 2018 17:25:25 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Make com.mongodb.client packages a NonNullApi and add Nullable annotations to methods and parameters that require it&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/28c1c46e62f7adf8f974667413bd7e84480f785b&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/28c1c46e62f7adf8f974667413bd7e84480f785b&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1838541" author="xgen-internal-githook" created="Mon, 19 Mar 2018 17:25:22 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Make com.mongodb a NonNullApi and add Nullable annotations to methods and parameters that require it&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/ab4a6a17c9756a0232e037d221d503c2640eac00&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/ab4a6a17c9756a0232e037d221d503c2640eac00&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1838540" author="xgen-internal-githook" created="Mon, 19 Mar 2018 17:25:21 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Make com.mongodb.async.client and com.mongodb.async.client.gridfs a NonNullApi and add Nullable annotations to methods and parameters that require it&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/4379ce188acbd18614a10b2805c0bc63af4d484c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/4379ce188acbd18614a10b2805c0bc63af4d484c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1838539" author="xgen-internal-githook" created="Mon, 19 Mar 2018 17:25:19 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Make com.mongodb.client.internal a NonNullApi and add Nullable annotations to methods and parameters that require it&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/2de302ff1d7c2abed67662f4d1d74ed6a83c5961&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/2de302ff1d7c2abed67662f4d1d74ed6a83c5961&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1838538" author="xgen-internal-githook" created="Mon, 19 Mar 2018 17:25:17 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Make com.mongodb.client and com.mongodb.client.gridfs a NonNullApi and add Nullable annotations to methods and parameters that require it&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/de2370c0b8651201b2c028669df6c1bbf8bc37c1&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/de2370c0b8651201b2c028669df6c1bbf8bc37c1&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1838537" author="xgen-internal-githook" created="Mon, 19 Mar 2018 17:25:12 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;email&apos;: &apos;jeff.yemin@10gen.com&apos;, &apos;name&apos;: &apos;Jeff Yemin&apos;, &apos;username&apos;: &apos;jyemin&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2641&quot; title=&quot;Add JSR-305-compatible NonNull annotations to the driver API&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2641&quot;&gt;&lt;del&gt;JAVA-2641&lt;/del&gt;&lt;/a&gt;: Add custom annotations using JSR-305 meta-annotatios&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/2d6c0691c8cfdf2f872f7405f3ce4f17da3c84b0&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/2d6c0691c8cfdf2f872f7405f3ce4f17da3c84b0&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1760508" author="mp911de" created="Wed, 27 Dec 2017 23:24:19 +0000"  >&lt;p&gt;Spring Framework&apos;s (Non)Nullability annotations are intended primarily to assist developers during development time within their IDE. Our annotations are annotated with proper JSR-305 annotations to comply with JSR-305&apos;s ideas. JSR-305 is not required to be on the classpath during development-time/compile-time/runtime of user-code. Our public API defaults to non-null by annotating packages with &lt;tt&gt;@NonNullApi&lt;/tt&gt;. Exceptions to non-nullability defaults (parameters, method return, fields) are annotated with &lt;tt&gt;@Nullable&lt;/tt&gt;. &lt;tt&gt;@NonNull&lt;/tt&gt; is used for rather punctual non-nullability indications without requiring to alter a whole package.&lt;/p&gt;

&lt;p&gt;We have additional runtime support based on our annotations to allow/reject &lt;tt&gt;null&lt;/tt&gt; values in method arguments and return values on controller and repository API if user-code is annotated using Spring Framework&apos;s annotations. If JSR-305 annotations are on the class-path, then we can leverage these, too (e.g. user-defined meta-annotations), but that&apos;s totally optional.&lt;/p&gt;

&lt;p&gt;We&apos;re expressing nullability constraints using Spring Framework&apos;s annotations on our public API. We&apos;re using Lombok&apos;s &lt;tt&gt;@Nonnull&lt;/tt&gt; in combination with &lt;tt&gt;@RequiredArgsConstructor&lt;/tt&gt; to generate non-null checks.&lt;/p&gt;</comment>
                            <comment id="1760459" author="jeff.yemin" created="Wed, 27 Dec 2017 22:02:07 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=mpaluch%40paluch.biz&quot; class=&quot;user-hover&quot; rel=&quot;mpaluch@paluch.biz&quot;&gt;mpaluch@paluch.biz&lt;/a&gt; &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=cstrobl&quot; class=&quot;user-hover&quot; rel=&quot;cstrobl&quot;&gt;cstrobl&lt;/a&gt;  Can either of you elaborate on the thinking behind taking the JSR-305 dependency in the Spring Framework, given the issues with the Java 9 module system (and perhaps OSGi)?  And why are the nullability-related Lombok annotations used in some places, but quite sparingly?  Was any thought given to more pervasive use of run-time null checks using code generation, as Lombok supports with its annotation processor?&lt;/p&gt;</comment>
                            <comment id="1747496" author="jeff.yemin" created="Fri, 8 Dec 2017 22:30:15 +0000"  >&lt;p&gt;A few additional notes:&lt;/p&gt;

&lt;ul&gt;
	&lt;li&gt;The Spring Framework has defined their own annotation that use JSR-305 annotations as meta-annotations.  The annotations are
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;https://github.com/spring-projects/spring-framework/blob/v5.0.2.RELEASE/spring-core/src/main/java/org/springframework/lang/NonNull.java&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;org.springframework.lang.NonNull&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;https://github.com/spring-projects/spring-framework/blob/v5.0.2.RELEASE/spring-core/src/main/java/org/springframework/lang/Nullable.java&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;org.springframework.lang.Nullable&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;https://github.com/spring-projects/spring-framework/blob/v5.0.2.RELEASE/spring-core/src/main/java/org/springframework/lang/NonNullApi.java&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;org.springframework.lang.NonNullApi&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/li&gt;
	&lt;li&gt;Kotlin has &lt;a href=&quot;https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;JSR-305 support&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So one option is to emulate Spring&apos;s technique, which centralizes the JSR-305 references to just a few annotations.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10520">
                    <name>Problem/Incident</name>
                                            <outwardlinks description="causes">
                                        <issuelink>
            <issuekey id="557683">JAVA-2886</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                                                <inwardlinks description="is related to">
                                        <issuelink>
            <issuekey id="566850">JAVA-2901</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="513481">JAVA-2814</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_10857" key="com.pyxis.greenhopper.jira:gh-epic-link">
                        <customfieldname>Epic Link</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>JAVA-2684</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hr94bb:</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>