Skip to content

Assertion does not match its error message and comments for QueryOptions.readTimeout method #1494

Closed
@seungh0

Description

@seungh0

Hi there,
I noticed a discrepancy between the comments and error messages in the QueryOptions.ReadTimeout method and the actual behavior of the code.
I suggest allowing the code to accept 0 without raising an exception to handle disabling the timeout.

/**
* Sets the request timeout. Overrides the default timeout.
*
* @param timeout the read timeout. Negative values are not allowed. If it is {@code 0}, the read timeout will be
* disabled for this statement.
* @return {@code this} {@link QueryOptionsBuilder}
* @see com.datastax.oss.driver.api.core.cql.SimpleStatement#setTimeout(Duration)
* @since 3.0
*/
public QueryOptionsBuilder timeout(Duration timeout) {
Assert.isTrue(!timeout.isZero() && !timeout.isNegative(), "ReadTimeout must be greater than equal to zero");
this.timeout = timeout;
return this;
}

I've also submitted a PR to address this. I would appreciate it if you could review it.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions