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

DefaultCommandMethodVerifier reports invalid parameter count #925

Closed
GhaziTriki opened this issue Nov 21, 2018 · 2 comments
Closed

DefaultCommandMethodVerifier reports invalid parameter count #925

GhaziTriki opened this issue Nov 21, 2018 · 2 comments
Labels
type: bug A general bug
Milestone

Comments

@GhaziTriki
Copy link

Bug Report

Current Behavior

Assuming we have declared a an increment command. An exception is raised.


Caused by: io.lettuce.core.dynamic.CommandMethodSyntaxException: Command INCR accepts 1 parameters but method declares 2 parameter(s). Offending method: public abstract java.lang.Long org.bigbluebutton.common2.redis.commands.RecordingCommands.incrementRecords(java.lang.String)
    at io.lettuce.core.dynamic.DefaultCommandMethodVerifier.validateParameters(DefaultCommandMethodVerifier.java:109)
    at io.lettuce.core.dynamic.DefaultCommandMethodVerifier.validate(DefaultCommandMethodVerifier.java:71)
    at io.lettuce.core.dynamic.ExecutableCommandLookupStrategySupport$DefaultCommandFactoryResolver.resolveRedisCommandFactory(ExecutableCommandLookupStrategySupport.java:74)
    at io.lettuce.core.dynamic.ExecutableCommandLookupStrategySupport.resolveCommandFactory(ExecutableCommandLookupStrategySupport.java:48)
    at io.lettuce.core.dynamic.AsyncExecutableCommandLookupStrategy.resolveCommandMethod(AsyncExecutableCommandLookupStrategy.java:47)
    at io.lettuce.core.dynamic.RedisCommandFactory$CompositeCommandLookupStrategy.resolveCommandMethod(RedisCommandFactory.java:273)
    at io.lettuce.core.dynamic.RedisCommandFactory$BatchAwareCommandLookupStrategy.resolveCommandMethod(RedisCommandFactory.java:321)
    at io.lettuce.core.dynamic.RedisCommandFactory$CommandFactoryExecutorMethodInterceptor.<init>(RedisCommandFactory.java:212)
    at io.lettuce.core.dynamic.RedisCommandFactory.getCommands(RedisCommandFactory.java:192)

Input Code

public interface RecordingCommands extends Commands {
    @Command("INCR ?0")
    Long incrementRecords(String key);
}

Expected behavior/code

The code above should work without raising any exception.

Environment

  • Lettuce version(s): 5.1.2-RELEASE
  • Redis version: Redis 3.0.6 (00000000/0) 64 bit
@mp911de
Copy link
Collaborator

mp911de commented Nov 23, 2018

The problem is that DefaultCommandMethodVerifier counts the parameters given by the method signature and adds any parameter bind markers to that. Therefore, it ends up with twice as many arguments.

@mp911de mp911de changed the title Error : Command INCR accepts 1 parameters but method declares 2 parameter(s) DefaultCommandMethodVerifier reports invalid parameter count Nov 23, 2018
mp911de added a commit that referenced this issue Nov 23, 2018
Lettuce now considers declared parameters when bound by using annotations. Previously, DefaultCommandMethodVerifier counted method arguments and bind markers as individual parameters which doubled the number of command args so command validation failed.
mp911de added a commit that referenced this issue Nov 23, 2018
Lettuce now considers declared parameters when bound by using annotations. Previously, DefaultCommandMethodVerifier counted method arguments and bind markers as individual parameters which doubled the number of command args so command validation failed.
@mp911de
Copy link
Collaborator

mp911de commented Nov 23, 2018

That's fixed now.

@mp911de mp911de closed this as completed Nov 23, 2018
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