Spring Batch
  1. Spring Batch
  2. BATCH-1826

Null pointer exception if optional parameter of type DATE is null

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.5
    • Fix Version/s: 2.1.9
    • Component/s: Core

      Description

      Selecting some of the jobs in spring-batch-admin leads to the following exception:

      (Issue occurs when we use spring-batch-admin latest release version which internally uses spring-batch-core 2.1.5)

      java.lang.IllegalArgumentException: Cannot format given Object as a Date
      java.text.DateFormat.format(DateFormat.java:301)
      java.text.Format.format(Format.java:157)
      org.springframework.batch.core.converter.DefaultJobParametersConverter
      .getProperties(DefaultJobParametersConverter.java:159)
      org.springframework.batch.admin.web.JobInstanceInfo.<init>(JobInstanceInfo.java:42)
      org.springframework.batch.admin.web.JobController.details(JobController.java:171)

      Found that the exception occurs in : DefaultJobParametersConverter.java line no:158 (in spring batch core v2.1.5)

      if (jobParameter.getType() == ParameterType.DATE) {
      result.setProperty(key + DATE_TYPE, dateFormat.format(value));
      }

      when "value" is null.
      Ideally there should be check to ignore null valued parameters.

      This can be fixed by :
      158 : if(value != null)

      { 168 : }

      Can someone check this?

      Thanks,
      Gayathri

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Robert Kasanicky
            Reporter:
            Gayathri Muralidharan
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: