Skip to content

Commit 73391cf

Browse files
authored
fix: compute redis name npe (#430)
1 parent 4b2e911 commit 73391cf

File tree

1 file changed

+6
-1
lines changed
  • arex-instrumentation/redis/arex-redis-common/src/main/java/io/arex/inst/redis/common

1 file changed

+6
-1
lines changed

arex-instrumentation/redis/arex-redis-common/src/main/java/io/arex/inst/redis/common/RedisExtractor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.arex.agent.bootstrap.model.Mocker;
55

66
import io.arex.agent.bootstrap.util.CollectionUtil;
7+
import io.arex.agent.bootstrap.util.StringUtil;
78
import io.arex.inst.runtime.serializer.Serializer;
89
import io.arex.inst.runtime.util.IgnoreUtils;
910
import io.arex.inst.runtime.util.MockUtils;
@@ -14,6 +15,7 @@
1415

1516
public class RedisExtractor {
1617
private static final String SPECIAL_CLASS_NAME = "redis.clients.jedis.BinaryJedis$SetFromList";
18+
private static final String DEFAULT_CLUSTER_NAME = "Cluster";
1719

1820
private final String clusterName;
1921
private final String command;
@@ -89,7 +91,10 @@ static class RedisCluster {
8991
private static final AtomicInteger sequence = new AtomicInteger();
9092

9193
static String get(String key) {
92-
return REDIS_CLUSTER_CACHE.computeIfAbsent(key, k -> "Cluster" + sequence.addAndGet(1));
94+
if(StringUtil.isEmpty(key)){
95+
return DEFAULT_CLUSTER_NAME;
96+
}
97+
return REDIS_CLUSTER_CACHE.computeIfAbsent(key, k -> DEFAULT_CLUSTER_NAME + sequence.addAndGet(1));
9398
}
9499
}
95100
}

0 commit comments

Comments
 (0)