New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScheduledTaskRegistrar's task list getters fail with NPE when no tasks set [SPR-13680] #18255

Closed
spring-issuemaster opened this Issue Nov 12, 2015 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

spring-issuemaster commented Nov 12, 2015

Vikram Palakurthi opened SPR-13680 and commented

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.


Affects: 4.2.2

Issue Links:

  • #17345 Allowing access to scheduled tasks in the ScheduledTaskRegistrar

Referenced from: commits 6d5c646, 3cb926e, 55d2055

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 12, 2015

Vikram Palakurthi commented

Added the new changes in this pull request.

#918

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 13, 2015

Juergen Hoeller commented

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

Juergen

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

spring-issuemaster commented Nov 13, 2015

Juergen Hoeller commented

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment