Skip to content

Commit

Permalink
remove special case in get_timeout_from_cmd_args
Browse files Browse the repository at this point in the history
  • Loading branch information
TJ Zhang committed Jun 30, 2024
1 parent 6bd5fab commit 72485cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 0 additions & 4 deletions glide-core/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,8 @@ fn get_timeout_from_cmd_arg(
format!("Received timeout = {:?}.", timeout_secs),
)))
} else if timeout_secs == 0.0 {
if std::str::from_utf8(&cmd.command().unwrap_or_default()) == Ok("WAIT") {
Ok(RequestTimeoutOption::ClientConfig)
} else {
// `0` means we should set no timeout
Ok(RequestTimeoutOption::NoTimeout)
}
} else {
// We limit the maximum timeout due to restrictions imposed by Redis and the Duration crate
if timeout_secs > u32::MAX as f64 {
Expand Down
6 changes: 6 additions & 0 deletions java/integTest/src/test/java/glide/SharedCommandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -8084,6 +8084,12 @@ public void wait_timeout_check(BaseClient client) {

// ensure that commands doesn't time out even if timeout > request timeout
assertEquals((client instanceof RedisClient ? 0 : 1), testClient.wait(1L, 1000L).get());

// with 0 timeout (no timeout) wait should block forever,
// but we wrap the test with timeout to avoid test failing or being stuck forever
assertThrows(
TimeoutException.class, // <- future timeout, not command timeout
() -> testClient.wait(1L, 0L).get(1, TimeUnit.SECONDS));
}
}
}

0 comments on commit 72485cf

Please sign in to comment.