Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RedisClient not closed when RedisCommands forgot to quit. #135

Closed
kentyeh opened this issue Jun 29, 2021 · 1 comment · Fixed by #136
Closed

RedisClient not closed when RedisCommands forgot to quit. #135

kentyeh opened this issue Jun 29, 2021 · 1 comment · Fixed by #136

Comments

@kentyeh
Copy link

kentyeh commented Jun 29, 2021

When following code was running, redisClient meet a EOFException and program hang on.

RedisServer redis = RedisServer.newRedisServer(6379);
redis.start();
try {
    RedisClient redisClient = RedisClient.create("redis://passwd@127.0.0.1:6379/0");
    try (StatefulRedisConnection<String, String> connection = redisClient.connect()) {
        RedisCommands<String, String> syncCommands = connection.sync();
        syncCommands.set("key", "Hello World!");
        System.out.printf("%s\n", syncCommands.get("key"));
        //syncCommands.quit();
    }
    redisClient.shutdown();
} finally {
    redis.stop();
}

Please add socket close check to RedisClient's run() procedure
from

while (running.get()) {
    Optional<RedisCommand> command = nextCommand();
    ...

to

while (running.get()) {
    if (socket.isClosed()){
        close(); //resources release here.
    }else{
        Optional<RedisCommand> command = nextCommand();
    ...
inponomarev added a commit that referenced this issue Jul 2, 2021
@inponomarev inponomarev mentioned this issue Jul 2, 2021
inponomarev added a commit that referenced this issue Jul 2, 2021
@inponomarev
Copy link
Collaborator

Hi @kentyeh , thanks for your proposal, expect the fix in the next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants