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

ScheduledTaskRegistrar's task list getters fail with NPE when no tasks set

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 4.2.2
    • Fix Version/s: 4.2.3
    • Component/s: Core
    • Labels:
    • Last commented by a User:
      false

      Description

      The ScheduledTaskRegistrar must be improved by adding few more helper methods.

      1. hasTriggerTasks()
      2. hasCronTasks()
      3. hasFixedRateTasks()
      4. hasFixedDelayTasks()

      The reason I am adding these helper methods as I tried accessing one of the getTriggerTaskList(), getCronTaskList(), getFixedRateTaskList(), getFixedDelayTaskList() which try to return a Collections.unmodifiableList list which does not accept a list object that is not instantiated (null) and throws a null pointer exception in case of null. This left me no other way to do null checks. Adding the helper methods would provide me if I should/shouldn't access it. There is already a helper method hasTasks but does not fit the solution to know if a specific TaskList is empty or null.

        Issue Links

          Activity

          Hide
          mrtinkz Vikram Palakurthi added a comment -

          Added the new changes in this pull request.

          https://github.com/spring-projects/spring-framework/pull/918

          Show
          mrtinkz Vikram Palakurthi added a comment - Added the new changes in this pull request. https://github.com/spring-projects/spring-framework/pull/918
          Hide
          juergen.hoeller Juergen Hoeller added a comment -

          I've rather added checks to the getter methods, explicitly returning null now if the underlying list is null. Thanks for raising this!

          Juergen

          Show
          juergen.hoeller Juergen Hoeller added a comment - I've rather added checks to the getter methods, explicitly returning null now if the underlying list is null . Thanks for raising this! Juergen
          Hide
          juergen.hoeller Juergen Hoeller added a comment - - edited

          After further consideration, I've changed the getters to return an empty List instead of null, allowing for uniform access in case of emptiness.

          Juergen

          Show
          juergen.hoeller Juergen Hoeller added a comment - - edited After further consideration, I've changed the getters to return an empty List instead of null , allowing for uniform access in case of emptiness. Juergen

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              mrtinkz Vikram Palakurthi
              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:
                2 years, 15 weeks, 1 day ago