Fix ClusterConnectionManager#calcSlot bug.

Signed-off-by: dengliming <liming.d.pro@gmail.com>
pull/2995/head
dengliming 5 years ago
parent 20a8d093bf
commit 6173a26703

@ -718,7 +718,9 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
int start = indexOf(key, (byte) '{');
if (start != -1) {
int end = indexOf(key, (byte) '}');
key = Arrays.copyOfRange(key, start+1, end);
if (end != -1 && start + 1 < end) {
key = Arrays.copyOfRange(key, start + 1, end);
}
}
int result = CRC16.crc16(key) % MAX_SLOT;
@ -734,7 +736,9 @@ public class ClusterConnectionManager extends MasterSlaveConnectionManager {
int start = key.indexOf('{');
if (start != -1) {
int end = key.indexOf('}');
key = key.substring(start+1, end);
if (end != -1 && start + 1 < end) {
key = key.substring(start + 1, end);
}
}
int result = CRC16.crc16(key.getBytes()) % MAX_SLOT;

@ -528,9 +528,9 @@ public class RedissonSetTest extends BaseTest {
.setLoadBalancer(new RandomLoadBalancer())
.addNodeAddress(process.getNodes().stream().findAny().get().getRedisServerAddressAndPort());
RedissonClient redisson = Redisson.create(config);
int size = 10000;
RSet<String> set = redisson.getSet("test");
RSet<String> set = redisson.getSet("{test");
for (int i = 0; i < size; i++) {
set.add("" + i);
}
@ -541,7 +541,7 @@ public class RedissonSetTest extends BaseTest {
}
assertThat(keys).hasSize(size);
redisson.shutdown();
process.shutdown();
}

Loading…
Cancel
Save