NamedParameterJdbcTemplate
throws unexpected exception for null
query
#31391
Labels
in: data
Issues in data modules (jdbc, orm, oxm, tx)
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
I was answering a question on StackOverflow which stated that the
NamedParameterJdbcTemplate
won't throw an exception when the query isnull
.Whilst creating a test for this I did notice that an exception was being thrown but not the exception that I expected. I was expecting an
IllegalArgumentException
from theNamedParameterUtils
with a proper error message stating the SQL cannot benull
.Instead however I was greeted with an exception from the
ConcurrentLruCache
.Stating that the
key
cannot benull
.While an exception is still being thrown (and it is a
NullPointerException
) it does feel like the wrong exception here. Looks like a regression from the introduction/rewrite of theConcurrentLruCache
. It might be better to copy (or move?) the check from theNamedParameterUtils
as a fail fast to theNamedParameterJdbcTemplate
instead.Spring Version 6.1.0-SNAPSHOT but probably applies to earlier versions as well.
The text was updated successfully, but these errors were encountered: