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

Synchronous dispatch of MULTI returns null #1335

Closed
tzxyz opened this issue Jul 7, 2020 · 2 comments
Closed

Synchronous dispatch of MULTI returns null #1335

tzxyz opened this issue Jul 7, 2020 · 2 comments
Labels
type: bug A general bug
Milestone

Comments

@tzxyz
Copy link
Contributor

tzxyz commented Jul 7, 2020

Bug Report

Current Behavior

public class LettuceTest {

    private final RedisClient client = RedisClient.create("redis://localhost");

    private final StatefulRedisConnection<String, String> connection = client.connect();

    @Test
    public void test() {
        String result = connection.sync().dispatch(CommandType.MULTI, new StatusOutput<String, String>(StringCodec.ASCII));
        Assert.assertSame("OK", result);	// expected return "OK" but null
    }
}
Stack trace
// your stack trace here;

Input Code

Input Code
        String result = connection.sync().multi();    // return "OK" 
        String customCommandResult = connection.sync().dispatch(CommandType.MULTI, new StatusOutput<String, String>(StringCodec.ASCII));    // return null

Expected behavior/code

Environment

  • Lettuce version(s): [e.g. 5.2.1.RELEASE]
  • Redis version: [e.g. 4.0.10]

Possible Solution

in io.lettuce.core.FutureSyncInvocationHandler#isTransactionActive it shoule be

    private static boolean isNonTxControlMethod(String methodName, Object[] args) {
        return !methodName.equals("exec")
                && !methodName.equals("multi")
                && !methodName.equals("discard")
                && !(methodName.equals("dispatch") && args.length > 0 && args[0] == CommandType.MULTI)
                && !(methodName.equals("dispatch") && args.length > 0 && args[0] == CommandType.EXEC)
                && !(methodName.equals("dispatch") && args.length > 0 && args[0] == CommandType.DISCARD);
    }

Additional context

@tzxyz tzxyz added the type: bug A general bug label Jul 7, 2020
tzxyz added a commit to tzxyz/lettuce-core that referenced this issue Jul 7, 2020
@mp911de mp911de changed the title Custom commands MULTI return null Synchronous dispatch of MULTI returns null Jul 9, 2020
@mp911de mp911de added this to the 5.3.2 milestone Jul 9, 2020
@mp911de
Copy link
Collaborator

mp911de commented Jul 9, 2020

Thanks for raising the issue. It makes sense to return responses as we do the same for the regular API.

mp911de pushed a commit that referenced this issue Jul 9, 2020
mp911de added a commit that referenced this issue Jul 9, 2020
Rewrite condition for readability.

Original pull request: #1336
mp911de pushed a commit that referenced this issue Jul 9, 2020
mp911de added a commit that referenced this issue Jul 9, 2020
Rewrite condition for readability.

Original pull request: #1336
@mp911de
Copy link
Collaborator

mp911de commented Jul 9, 2020

Fixed via #1336.

@mp911de mp911de closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants