Philipp Shergalis created IGNITE-24791:
------------------------------------------

             Summary: Add range validations for timeout configurations
                 Key: IGNITE-24791
                 URL: https://issues.apache.org/jira/browse/IGNITE-24791
             Project: Ignite
          Issue Type: Improvement
            Reporter: Philipp Shergalis


We have a lot of timeouts without validations / partial validations. I.e:
{code:java}
/** * Timeout value (in milliseconds) for which the Raft client will try to 
receive a successful response from a remote peer. */
@Value(hasDefault = true) 
public long retryTimeout = 10_000;{code}
1) Timeouts must be positive

2) Timeouts are often used with subtractPhysicalTime(). Argument must be less 
than 2^48 (PHYSICAL_TIME_BITS_SIZE = 48)
{code:java}
public HybridTimestamp subtractPhysicalTime(long millis) {
if (millis >= (1L << PHYSICAL_TIME_BITS_SIZE)) {
throw new IllegalArgumentException("Physical time is out of bounds: " + millis);
}

return new HybridTimestamp(time - (millis << LOGICAL_TIME_BITS_SIZE));
}{code}
3) Subtracting a timeout from clock.now() should not cause "Time is out of 
bounds" exception
{code:java}
private HybridTimestamp(long time) {
    this.time = time;

    // Negative time breaks comparison, we don't allow overflow of the physical 
time.
    // "0" is a reserved value for "NULL_HYBRID_TIMESTAMP".
    if (time <= 0) {
        throw new IllegalArgumentException("Time is out of bounds: " + time);
    }
}{code}
At least 
{code:java}
@Range(min = 1, max = 1L << PHYSICAL_TIME_BITS_SIZE - 1){code}
should be added for timeout configurations



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to