# org.springframework.lang.Nullable is ignored in nullability analysis

**URL:** <https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946>\
**Category:** Report False-positive / False-negative...\
**Tags:** java\
**Created:** [April 20, 2021, 9:02am UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946 "2021-04-20T09:02:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vojtech.bisek](https://avatars.discourse-cdn.com/v4/letter/v/9e8a1a/32.png) [@vojtech.bisek](https://community.sonarsource.com/u/vojtech.bisek)\
**Post date:** [April 20, 2021, 9:02am UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946/1 "2021-04-20T09:02:55Z")

</div>

Versions used:

- Java 11.0.8 AdoptOpenJDK (64-bit)
- SonarQube Scanner 3.1.0.1141
- SonarQube server 8.1.0

When API nullability is established through `@NonNullApi`, exceptions specified through `@Nullable` (which is the [intent of the API](https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/lang/NonNullApi.html)) are ignored and multiple of nullability false positives are triggered.

`package-info.java`

```auto
@NonNullApi
package com.example;
import org.springframework.lang.NonNullApi;

```

`X.java`

```auto
import org.springframework.lang.Nullable;

public class X {
	public boolean isNull(@Nullable x) {
	  return x == null; // java:S2583
	}
	
	@Nullable public Object getNull() {
	  return null; // java:S2637
	}
}

```

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 20, 2021, 9:22am UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946/2 "2021-04-20T09:22:55Z")

</div>

Hey there.

SonarQube _v8.1_ was released in December 2019 and a lot has changed since then! Can you reproduce the issue on SonarQube _v8.8_?

Please also make sure that [parameters like `sonar.java.binaries` and `sonar.java.libraries`](https://docs.sonarqube.org/latest/analysis/languages/java/#header-2) are being filled correctly if you’re handling them manually (they should be handled automatically by the Scanner for Maven, Gradle, etc.)

---

<div class="post-metadata">

**Author:** ![vojtech.bisek](https://avatars.discourse-cdn.com/v4/letter/v/9e8a1a/32.png) [@vojtech.bisek](https://community.sonarsource.com/u/vojtech.bisek)\
**Post date:** [April 20, 2021, 10:58am UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946/3 "2021-04-20T10:58:17Z")

</div>

Sorry, I don’t have access to newer versions, the instance I use is governed by our corporate IT.  
Are you implying you can’t reproduce it with a recent version or that you simply don’t look at issues unless they can be reproduced with a newer version?

I will definitely doublecheck the highlighted parameters.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 20, 2021, 12:35pm UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946/4 "2021-04-20T12:35:08Z")

</div>

A non-LTS version of SonarQube becomes unsupported as soon as a new version is released, which is why we suggest the following:

> [@How to Report a False-positive / False-negative](https://community.sonarsource.com/t/how-to-report-a-false-positive-false-negative/37022/1):
>
> ⚠ When possible, please try and reproduce the issue using the latest releases of our products. You might get lucky! Our products are continuously improving, and investigating an issue we’ve already fixed isn’t fun for anybody. **Your report is much more likely to get attention if you are using a fresh release.**

---

<div class="post-metadata">

**Author:** ![vojtech.bisek](https://avatars.discourse-cdn.com/v4/letter/v/9e8a1a/32.png) [@vojtech.bisek](https://community.sonarsource.com/u/vojtech.bisek)\
**Post date:** [April 20, 2021, 12:59pm UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946/5 "2021-04-20T12:59:48Z")

</div>

Sure, I’ve read that and I already clarified that using a new version is “not possible”. I will interpret your response as “haven’t tried to reproduce”.

---

<div class="post-metadata">

**Author:** ![Michael](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/michael/32/43_2.png) [@Michael](https://community.sonarsource.com/u/Michael)\
**Post date:** [April 26, 2021, 3:18pm UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946/7 "2021-04-26T15:18:40Z")

</div>

Hello Vojtech,

Thanks for reporting this.

> [@vojtech.bisek](#):
>
> I’ve read that and I already clarified that using a new version is “not possible”

That’s unfortunate because we won’t be able to help you much. This SonarQube version is not maintained and not supported anymore. Your corporate IT is obviously not following our guidelines regarding using non-LTS versions of SonarQube.

> [@vojtech.bisek](#):
>
> I will interpret your response as “haven’t tried to reproduce”.

For your information, your use case can not be reproduced with the latest released version of SonarQube (8.8), which embeds version 6.14 of the Java Analyzer. To me, the issue you might be facing has been solved by this ticket: [SONARJAVA-3447](https://jira.sonarsource.com/browse/SONARJAVA-3447). This was indeed an FP and a wrong interpretation of the annotation.

The fix was released as part of version 6.7 of the Java Analyzer, which was itself only available with SonarQube 8.5 (_not maintained anymore_). As of today, the only way to benefit from the fix, as well as all the other fixes and features we added since then would be to update to the latest version of SonarQube.

Unfortunately for you, you made it clear that it is absolutely “not possible”.

Good luck,  
Michael

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [May 3, 2021, 3:19pm UTC](https://community.sonarsource.com/t/org-springframework-lang-nullable-is-ignored-in-nullability-analysis/41946/9 "2021-05-03T15:19:50Z")

</div>

Closed on May 3, 2021, 3:19pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
