Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-16843

Problem with passing null parameter to MapSqlParameterSource

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.0.5
    • Fix Version/s: 5.0.8, 5.1 RC1
    • Component/s: Data:JDBC
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      I have following problem when pass null to MapSqlParameterSource

       

      {{ final MapSqlParameterSource paramMap = new MapSqlParameterSource()
      .addValue("ALERT_ID", null);}}

      Code Warning
      NP Null passed for non-null parameter of org.springframework.jdbc.core.namedparam.MapSqlParameterSource.addValue(String, Object) in bug.DocDao.test()
        Bug type NP_NONNULL_PARAM_VIOLATION (click for details) In class bug.DocDaoIn method bug.DocDao.test()Called method org.springframework.jdbc.core.namedparam.MapSqlParameterSource.addValue(String, Object)Argument 2 is definitely null but must not be nullAt DocDao.java:[line 15]

      In my case null is valid value for database.
      Sample code is attached here
      https://github.com/lengarski/bug

      Here is the response from spotbugs
      spotbugs/spotbugs#642

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                lengarski Georgi Lengarski
                Last updater:
                Stéphane Nicoll
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 weeks, 1 day ago