jakartaee / enterprise-beans

Jakarta Enterprise Beans
https://eclipse.org/ee4j/ejb
Other
20 stars 29 forks source link

Timer schedule increment value 0 #148

Open chengfang opened 1 year ago

chengfang commented 1 year ago

This timer service section states that:

For an expression x/y, the attribute is constrained to every yth value within the set of allowable values beginning at time x. The x value is inclusive. The wildcard character (*) can be used in the x position, and is equivalent to 0. Increments are only supported within the second, minute, and hour attributes. For the second and minute attributes, x and y must each be in the range [0,59]. For the hour attribute, x and y must each be in the range [0,23].

Given the value range of [0, 59], 0 increment value as in second="10/0" fall into the valid range, though 0 increment value doesn't seem right. What's the expected behavior here?

Shall we consider "10/0" as equivalent to a single-value "10", or consider it invalid?

tkburroughs commented 1 year ago

Since the specification does state 0 is a valid value, I believe "10/0" should be valid. Looking at this example from the specification:

Example: Every 10 seconds within the minute, starting at second 30
second = "30/10"
The following is equivalent:
second = "30,40,50"

The value "30" being the initial value, and then incrementing "10" would result in the 40 and 50 values. It would seem the only way to treat "30/0" as valid would be to have the initial value of "30", and then the "0" would result in no increment, so the equivalent to "30/0" would be just "30"... as you suggest. Thus, the specification could provide an example like this:

Example: Every 0 seconds within the minute, starting at second 30
second = "30/0"
The following is equivalent:
second = "30"