1

Sonarqube notice a bug while checking the result value from Spring-JDBC "JdbcTemplate.queryForObject()" for null.

After checking the source in deep, we are not sure why sonar thinks that this value can never be null. Even the javadoc tells us that this value could be nullable, and since we expect an object to return, it should be able to be null.

It is also written in the javadoc that the method is able to return null in case:

@return the result object of the required type, or {@code null} in case of SQL NULL

sonar screenshot

Why can this Integer not be null here ?

The calling method here is JdbcTemplate.java L:802 in Spring-jdbc 5.1.6

Spring JDBC Version 5.1.6
Sonarqube Version 6.7.5

Christof Buechi
  • 163
  • 1
  • 12
  • 2
    I believe this is a dup of https://stackoverflow.com/questions/46836447 where there is bug in Sonar re: @Nullable. We suppress this warning by adding @SuppressWarnings("squid:S2583") – Jayr May 21 '19 at 16:38

0 Answers0