Skip to content

Commit

Permalink
Fix NPE in test clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ggivo committed Nov 19, 2024
1 parent a34d631 commit 1698b76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public void setUp() throws InterruptedException {
int[] node1Slots = new int[slotsPerNode];
int[] node2Slots = new int[slotsPerNode + 1];
int[] node3Slots = new int[slotsPerNode];
// for (int i = 0, slot1 = 0, slot2 = 0, slot3 = 0; i < JedisCluster.HASHSLOTS; i++) {
for (int i = 0, slot1 = 0, slot2 = 0, slot3 = 0; i < CLUSTER_HASHSLOTS; i++) {
if (i < slotsPerNode) {
node1Slots[slot1++] = i;
Expand All @@ -76,28 +75,25 @@ public void setUp() throws InterruptedException {
waitForClusterReady();

jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
// cluster = new JedisCluster(jedisClusterNode, 2000, 2000, 5, "cluster", new JedisPoolConfig());
// cluster = new JedisCluster(jedisClusterNode, DefaultJedisClientConfig.builder().password("cluster").build(), 5);
cluster = new JedisCluster(jedisClusterNode, null, "cluster");

}

@AfterClass
public static void cleanUp() {
int slotTest = JedisClusterCRC16.getSlot("test");
int slot51 = JedisClusterCRC16.getSlot("51");
String node3Id = getNodeId(node3.clusterNodes());
node2.clusterSetSlotNode(slotTest, node3Id);
node2.clusterSetSlotNode(slot51, node3Id);
node2.clusterDelSlots(slotTest, slot51);
if (node3 != null ) {
String node3Id = getNodeId(node3.clusterNodes());
node2.clusterSetSlotNode(slotTest, node3Id);
node2.clusterSetSlotNode(slot51, node3Id);
node2.clusterDelSlots(slotTest, slot51);
}
}

@After
public void tearDown() {
// clear all slots
// int[] slotsToDelete = new int[JedisCluster.HASHSLOTS];
int[] slotsToDelete = new int[CLUSTER_HASHSLOTS];
// for (int i = 0; i < JedisCluster.HASHSLOTS; i++) {
for (int i = 0; i < CLUSTER_HASHSLOTS; i++) {
slotsToDelete[i] = i;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import java.util.Map;

import io.redis.test.annotations.SinceRedisVersion;
import io.redis.test.utils.RedisVersion;
import io.redis.test.utils.RedisVersionRule;
import org.junit.Rule;
import org.junit.Test;

import redis.clients.jedis.BinaryJedisShardedPubSub;
Expand Down

0 comments on commit 1698b76

Please sign in to comment.