Skip to content

2.x: schedulePeriodically with non-positive period #5416

Closed
@akarnokd

Description

@akarnokd

Currently, the Scheduler and Worker API allows for non-positive periods on periodically scheduling but the underlying ScheduledExecutorServices don't. The javadoc doesn't specify any restrictions on period unlike initialDelay or delay where a non-positive value is considered to be an "execute without delay".

In theory, the default periodic logic could handle the case by executing such periodic tasks without any delay but I'm not certain the behavior is actually desired.

Related StackOverflow question: https://stackoverflow.com/questions/44555253/spring-boot-and-rxjava2-integration-nullpointerexception-actually-not

So the tw options I see are as follows:

  1. throw IAE with non-positive periods with the related operators and require the Scheduler/Worker API to do the same
  2. allow 0 period and introduce workarounds inside the Scheduler/Worker implementations.

I prefer option 1 as nobody seem to have encountered this specific issue before that would have rendered the code inoperable anyway due to a crash similar to the SO case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions