forked from valkey-io/valkey-glide
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor channel closure handling (#118)
* Ensure resources complete with Closing Error when client closes. New command submissions on closed clients now also return a future with a ClosingException Set. (Consistent with Py and Node clients) * Added a private boolean that saves the state of channel handler. * Changed Boolean to Atomic Boolean added IT tests and modified UT tests. * Fix IT
- Loading branch information
1 parent
5f687a3
commit 2290ddf
Showing
7 changed files
with
90 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
java/integTest/src/test/java/glide/cluster/ClientTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.cluster; | ||
|
||
import static glide.TestConfiguration.CLUSTER_PORTS; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import glide.api.RedisClusterClient; | ||
import glide.api.models.configuration.NodeAddress; | ||
import glide.api.models.configuration.RedisClusterClientConfiguration; | ||
import glide.api.models.exceptions.ClosingException; | ||
import java.util.concurrent.ExecutionException; | ||
import lombok.SneakyThrows; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ClientTests { | ||
@Test | ||
@SneakyThrows | ||
public void close_client_throws_ExecutionException_with_ClosingException_cause() { | ||
RedisClusterClient client = | ||
RedisClusterClient.CreateClient( | ||
RedisClusterClientConfiguration.builder() | ||
.address(NodeAddress.builder().port(CLUSTER_PORTS[0]).build()) | ||
.build()) | ||
.get(); | ||
|
||
client.close(); | ||
ExecutionException executionException = | ||
assertThrows(ExecutionException.class, () -> client.set("foo", "bar").get()); | ||
assertTrue(executionException.getCause() instanceof ClosingException); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
java/integTest/src/test/java/glide/standalone/ClientTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 */ | ||
package glide.standalone; | ||
|
||
import static glide.TestConfiguration.STANDALONE_PORTS; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import glide.api.RedisClient; | ||
import glide.api.models.configuration.NodeAddress; | ||
import glide.api.models.configuration.RedisClientConfiguration; | ||
import glide.api.models.exceptions.ClosingException; | ||
import java.util.concurrent.ExecutionException; | ||
import lombok.SneakyThrows; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ClientTests { | ||
@Test | ||
@SneakyThrows | ||
public void close_client_throws_ExecutionException_with_ClosingException_cause() { | ||
RedisClient client = | ||
RedisClient.CreateClient( | ||
RedisClientConfiguration.builder() | ||
.address(NodeAddress.builder().port(STANDALONE_PORTS[0]).build()) | ||
.build()) | ||
.get(); | ||
|
||
client.close(); | ||
ExecutionException executionException = | ||
assertThrows(ExecutionException.class, () -> client.set("key", "value").get()); | ||
assertTrue(executionException.getCause() instanceof ClosingException); | ||
} | ||
} |