mirror of
https://gitee.com/devlive-community/datacap.git
synced 2024-12-02 12:07:37 +08:00
[Plugin] [Redis] Fixed command multiple parameters (#196)
This commit is contained in:
commit
3f6763406a
@ -18,7 +18,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@SuppressFBWarnings(value = {"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE"},
|
||||
@SuppressFBWarnings(value = {"RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", "REC_CATCH_EXCEPTION"},
|
||||
justification = "I prefer to suppress these FindBugs warnings")
|
||||
public class RedisAdapter
|
||||
extends NativeAdapter
|
||||
@ -43,12 +43,20 @@ public class RedisAdapter
|
||||
List<String> types = new ArrayList<>();
|
||||
List<Object> columns = new ArrayList<>();
|
||||
try {
|
||||
String[] commands = content.split(" ", 2);
|
||||
String[] commands = content.split(" ");
|
||||
Protocol.Command cmd = Protocol.Command.valueOf(commands[0].toUpperCase());
|
||||
Method method = MethodUtils.getMatchingMethod(Client.class, "sendCommand", Protocol.Command.class, String[].class);
|
||||
method.setAccessible(true);
|
||||
Client client = this.redisConnection.getJedis().getClient();
|
||||
method.invoke(client, cmd, new String[] {commands[1]});
|
||||
List<String> cmdParam = new ArrayList<>();
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
if (i == 0) {
|
||||
continue;
|
||||
}
|
||||
cmdParam.add(commands[i]);
|
||||
}
|
||||
String[] cmdParamArr = cmdParam.toArray(new String[]{});
|
||||
method.invoke(client, cmd, cmdParamArr);
|
||||
Object body = client.getOne();
|
||||
headers.add(commands[1]);
|
||||
types.add("String");
|
||||
|
@ -2,15 +2,15 @@ package io.edurt.datacap.plugin.natived.redis;
|
||||
|
||||
import io.edurt.datacap.spi.adapter.Adapter;
|
||||
import org.junit.Test;
|
||||
import io.edurt.datacap.spi.model.Response;
|
||||
|
||||
public class RedisAdapterTest
|
||||
extends RedisBaseTest
|
||||
{
|
||||
extends RedisBaseTest {
|
||||
@Test
|
||||
public void handlerExecute()
|
||||
{
|
||||
public void handlerExecute() {
|
||||
RedisConnection connection = new RedisConnection(this.configure, this.response);
|
||||
Adapter adapter = new RedisAdapter(connection);
|
||||
adapter.handlerExecute("GET key");
|
||||
Response cc = adapter.handlerExecute("keys asd");
|
||||
System.out.println(cc);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user