# java:S3516 Error detection

**URL:** <https://community.sonarsource.com/t/java-s3516-error-detection/79011>\
**Category:** Report False-positive / False-negative...\
**Created:** [December 16, 2022, 2:30am UTC](https://community.sonarsource.com/t/java-s3516-error-detection/79011 "2022-12-16T02:30:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![muii](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/muii/32/33230_2.png) [@muii](https://community.sonarsource.com/u/muii)\
**Post date:** [December 16, 2022, 2:30am UTC](https://community.sonarsource.com/t/java-s3516-error-detection/79011/1 "2022-12-16T02:30:15Z")

</div>

#### SonarQube version 9.7.1 (build 62043)

In my codes,a method is designed to return two values,One of them is `null`,another one is not `null`,like:

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/0/0/00c77a2cb423e7fcbdc8379412f99e7b3a5b58a8.png)

but you think these are the same value.

And in `SonarLint 7.2.1.58118(IDEA)` with the same rules as it,the same issue was not detected.

---

<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:** [December 19, 2022, 9:11am UTC](https://community.sonarsource.com/t/java-s3516-error-detection/79011/2 "2022-12-19T09:11:56Z")

</div>

Hey there.

Thanks for your feedback! I’ve moved your post to the section on reporting a false-positive.

As noted in this thread:

> [@How to Report a False-positive / False-negative](https://community.sonarsource.com/t/how-to-report-a-false-positive-false-negative/37022):
>
> Hey SonarSource Community! [False-positives happen](https://blog.sonarsource.com/false-positives-our-enemies-but-maybe-your-friends), as do false-negatives, and we’re eager to fix them. We are thrilled when our users report problems, so we can make our products better. What is a false-positive (FP)? A false-positive is when an issue is raised unexpectedly on code that should not trigger an issue, or where the suggested action doesn’t make any sense for the code. What is a false-negative (FN)? A false-negative is when an issue should be raised on a piece of code, but isn’t. …

Can you please provide a text-based code reproducer that raises the false-positive?

Thanks!

---

<div class="post-metadata">

**Author:** ![bjansen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/bjansen/32/18895_2.png) [@bjansen](https://community.sonarsource.com/u/bjansen)\
**Post date:** [February 1, 2023, 1:23pm UTC](https://community.sonarsource.com/t/java-s3516-error-detection/79011/3 "2023-02-01T13:23:39Z")

</div>

Hi,

I just came across the same FP. Here’s a very simple reproducer:

```java
	public boolean something() {
		try {
			return true;
		} catch (RuntimeException e) {
			LOGGER.debug("no", e);
		}
		return false;
	}

```

![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/2/0/20d8406c63219d182e2ef200f6593dd6b435e1b0.png)

Using SonarLint 7.4.0.60471 for IntelliJ.

---

<div class="post-metadata">

**Author:** ![bjansen](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/bjansen/32/18895_2.png) [@bjansen](https://community.sonarsource.com/u/bjansen)\
**Post date:** [February 1, 2023, 2:04pm UTC](https://community.sonarsource.com/t/java-s3516-error-detection/79011/4 "2023-02-01T14:04:45Z")

</div>

Then calling `something()` also triggers `java:S2589` which also thinks the returned value is always `true`.

---

<div class="post-metadata">

**Author:** ![Leonardo\_Pilastri](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/leonardo_pilastri/32/38853_2.png) [@Leonardo\_Pilastri](https://community.sonarsource.com/u/Leonardo_Pilastri)\
**Post date:** [February 27, 2023, 4:14pm UTC](https://community.sonarsource.com/t/java-s3516-error-detection/79011/7 "2023-02-27T16:14:57Z")

</div>

Hello there, there is already a ticket for this, as it is a known issue. We will try to fix it as soon as it will be possible for us! You can track its progress [here](https://sonarsource.atlassian.net/browse/SONARJAVA-3063).
