java:S3655 is not correct detect

Please provide

  • Operating system: MacOS Ventunar 13.0
  • SonarLint plugin version: 7.4.0.60471
  • Programming language you’re coding in: Java
  • Is connected mode used:
    • Connected to SonarCloud or SonarQube (and which version): no

And a thorough description of the problem/question:
I used isPresent already, but it still warns the bug

 // Optional<User> user = .....
	if (user.isPresent()) {
		new TransactionTemplate(transactionManager, attribute)
			.execute(new TransactionCallbackWithoutResult() {
				@Override
				protected void doInTransactionWithoutResult(TransactionStatus status) {
					sendingEmailService.sendRemindEmail(param, user.get());
				}
			});
		entityManager.clear();
		ReadOnlyEntityManager.clear();
	}

Hi @thachlp ,

Thank you for reporting, and sorry for the late reply.

This is a false positive, and here is a ticket for it. [SONARJAVA-4515] - Jira

All the best,

Irina

Is this issue really still open? We have lots of false positives as we use optional a lot. Will this be addressed any time at all? It is really annoying to resolve those false positives and it would also not be the best option to disable the rule at all.