Skip to content

Commit b92ab8f

Browse files
authored
Merge branch 'master' into pool-socket-factory
2 parents 256434e + a783c78 commit b92ab8f

17 files changed

+277
-323
lines changed

.circleci/config.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
version: 2.1
2+
3+
4+
executors:
5+
linux-8-jdk:
6+
docker:
7+
- image: circleci/openjdk:8-jdk
8+
linux-7-jdk:
9+
docker:
10+
- image: circleci/openjdk:7-jdk
11+
12+
jobs:
13+
build:
14+
parameters:
15+
os:
16+
type: executor
17+
18+
executor: << parameters.os >>
19+
20+
working_directory: ~/repo
21+
22+
environment:
23+
JVM_OPTS: -Xmx3200m
24+
TERM: dumb
25+
26+
steps:
27+
- checkout
28+
29+
# Download and cache dependencies
30+
- restore_cache:
31+
keys:
32+
- jedis-{{ checksum "pom.xml" }}
33+
34+
- run: mvn dependency:go-offline
35+
36+
- save_cache:
37+
paths:
38+
- ~/.m2
39+
key: jedis-{{ checksum "pom.xml" }}
40+
41+
- run: |
42+
sudo apt update
43+
sudo apt install -y stunnel
44+
45+
- run: make circleci-install
46+
47+
- run: TEST="\!ModuleTest" make test
48+
49+
50+
workflows:
51+
all-jdks:
52+
jobs:
53+
- build:
54+
matrix:
55+
parameters:
56+
# os: [linux-8-jdk, linux-7-jdk]
57+
os: [linux-8-jdk]

.github/workflows/build-jdk8.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,15 @@ travis-install:
379379
[ ! -e redis-git ] && git clone https://github.com/antirez/redis.git --branch unstable --single-branch redis-git || true
380380
$(MAKE) -C redis-git clean
381381
$(MAKE) -C redis-git
382+
383+
circleci-install:
384+
sudo apt-get install -y gcc-8 g++-8
385+
cd /usr/bin ;\
386+
sudo ln -sf gcc-8 gcc ;\
387+
sudo ln -sf g++-8 g++
388+
[ ! -e redis-git ] && git clone https://github.com/antirez/redis.git --branch unstable --single-branch redis-git || true
389+
$(MAKE) -C redis-git clean
390+
$(MAKE) -C redis-git
382391

383392
compile-module:
384393
gcc -shared -o /tmp/testmodule.so -fPIC src/test/resources/testmodule.c

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Release](https://img.shields.io/github/release/redis/jedis.svg)](https://github.com/redis/jedis/releases/latest)
2-
[![Build](https://github.com/redis/jedis/workflows/Build%20with%20JDK/badge.svg)](https://github.com/redis/jedis/actions)
2+
[![CircleCI](https://circleci.com/gh/redis/jedis/tree/master.svg?style=svg)](https://circleci.com/gh/redis/jedis/tree/master)
33
[![Maven Central](https://img.shields.io/maven-central/v/redis.clients/jedis.svg)](http://mvnrepository.com/artifact/redis.clients/jedis)
44
[![Javadocs](https://www.javadoc.io/badge/redis.clients/jedis.svg)](https://www.javadoc.io/doc/redis.clients/jedis)
55
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2-
32
<parent>
43
<groupId>org.sonatype.oss</groupId>
54
<artifactId>oss-parent</artifactId>
@@ -220,4 +219,4 @@
220219
</plugin>
221220
</plugins>
222221
</build>
223-
</project>
222+
</project>

src/main/java/redis/clients/jedis/BinaryClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ public void lpos(final byte[] key, final byte[] element, LPosParams params) {
385385
}
386386

387387
public void lpos(final byte[] key, final byte[] element, final LPosParams params, final long count){
388-
sendCommand(LPOS, joinParameters(key, element, params.getByteParams(toByteArray(count))));
388+
sendCommand(LPOS, joinParameters(key, element, params.getByteParams(Keyword.COUNT.raw, toByteArray(count))));
389389
}
390390

391391
public void rpop(final byte[] key) {

src/main/java/redis/clients/jedis/JedisClusterConnectionHandler.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@ private void initializeSlotsCache(Set<HostAndPort> startNodes,
6161
int connectionTimeout, int soTimeout, String user, String password, String clientName,
6262
boolean ssl, SSLSocketFactory sslSocketFactory, SSLParameters sslParameters, HostnameVerifier hostnameVerifier) {
6363
for (HostAndPort hostAndPort : startNodes) {
64-
Jedis jedis = null;
65-
try {
66-
jedis = new Jedis(hostAndPort.getHost(), hostAndPort.getPort(), connectionTimeout, soTimeout, ssl, sslSocketFactory, sslParameters, hostnameVerifier);
64+
try (Jedis jedis = new Jedis(hostAndPort.getHost(), hostAndPort.getPort(),
65+
connectionTimeout, soTimeout, ssl, sslSocketFactory, sslParameters, hostnameVerifier)) {
6766
if (user != null) {
6867
jedis.auth(user, password);
6968
} else if (password != null) {
@@ -73,13 +72,9 @@ private void initializeSlotsCache(Set<HostAndPort> startNodes,
7372
jedis.clientSetname(clientName);
7473
}
7574
cache.discoverClusterNodesAndSlots(jedis);
76-
break;
75+
return;
7776
} catch (JedisConnectionException e) {
7877
// try next nodes
79-
} finally {
80-
if (jedis != null) {
81-
jedis.close();
82-
}
8378
}
8479
}
8580
}

src/main/java/redis/clients/jedis/params/LPosParams.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
public class LPosParams extends Params {
1010

1111
private static final String RANK = "RANK";
12-
private static final String COUNT = "COUNT";
1312
private static final String MAXLEN = "MAXLEN";
1413

1514
public static LPosParams lPosParams() {
@@ -26,11 +25,6 @@ public LPosParams maxlen(int maxLen) {
2625
return this;
2726
}
2827

29-
public LPosParams count(int count) {
30-
addParam(COUNT, count);
31-
return this;
32-
}
33-
3428
public byte[][] getByteParams(byte[]... args) {
3529
ArrayList<byte[]> byteParams = new ArrayList<>();
3630
Collections.addAll(byteParams, args);
@@ -40,11 +34,6 @@ public byte[][] getByteParams(byte[]... args) {
4034
byteParams.add(Protocol.toByteArray((int) getParam(RANK)));
4135
}
4236

43-
if (contains(COUNT)) {
44-
byteParams.add(SafeEncoder.encode(COUNT));
45-
byteParams.add(Protocol.toByteArray((int) getParam(COUNT)));
46-
}
47-
4837
if (contains(MAXLEN)) {
4938
byteParams.add(SafeEncoder.encode(MAXLEN));
5039
byteParams.add(Protocol.toByteArray((int) getParam(MAXLEN)));

src/test/java/redis/clients/jedis/tests/JedisClusterTest.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public void testMigrateToNewNode() throws InterruptedException {
287287
jedisClusterNode.add(nodeInfo1);
288288
JedisCluster jc = new JedisCluster(jedisClusterNode, DEFAULT_TIMEOUT, DEFAULT_TIMEOUT,
289289
DEFAULT_REDIRECTIONS, "cluster", DEFAULT_CONFIG);
290-
node4.clusterMeet(localHost, nodeInfo1.getPort());
290+
node3.clusterMeet(localHost, nodeInfo4.getPort());
291291

292292
String node3Id = JedisClusterTestUtil.getNodeId(node3.clusterNodes());
293293
String node4Id = JedisClusterTestUtil.getNodeId(node4.clusterNodes());
@@ -379,29 +379,31 @@ public void testRedisClusterMaxRedirections() {
379379
public void testClusterForgetNode() throws InterruptedException {
380380
// at first, join node4 to cluster
381381
node1.clusterMeet("127.0.0.1", nodeInfo4.getPort());
382+
node2.clusterMeet("127.0.0.1", nodeInfo4.getPort());
383+
node3.clusterMeet("127.0.0.1", nodeInfo4.getPort());
382384

383-
String node7Id = JedisClusterTestUtil.getNodeId(node4.clusterNodes());
384-
385-
JedisClusterTestUtil.assertNodeIsKnown(node3, node7Id, 1000);
386-
JedisClusterTestUtil.assertNodeIsKnown(node2, node7Id, 1000);
387-
JedisClusterTestUtil.assertNodeIsKnown(node1, node7Id, 1000);
385+
String node4Id = JedisClusterTestUtil.getNodeId(node4.clusterNodes());
388386

389-
assertNodeHandshakeEnded(node3, 1000);
390-
assertNodeHandshakeEnded(node2, 1000);
387+
JedisClusterTestUtil.assertNodeIsKnown(node1, node4Id, 1000);
388+
JedisClusterTestUtil.assertNodeIsKnown(node2, node4Id, 1000);
389+
JedisClusterTestUtil.assertNodeIsKnown(node3, node4Id, 1000);
390+
391391
assertNodeHandshakeEnded(node1, 1000);
392+
assertNodeHandshakeEnded(node2, 1000);
393+
assertNodeHandshakeEnded(node3, 1000);
392394

393395
assertEquals(4, node1.clusterNodes().split("\n").length);
394396
assertEquals(4, node2.clusterNodes().split("\n").length);
395397
assertEquals(4, node3.clusterNodes().split("\n").length);
396398

397399
// do cluster forget
398-
node1.clusterForget(node7Id);
399-
node2.clusterForget(node7Id);
400-
node3.clusterForget(node7Id);
400+
node1.clusterForget(node4Id);
401+
node2.clusterForget(node4Id);
402+
node3.clusterForget(node4Id);
401403

402-
JedisClusterTestUtil.assertNodeIsUnknown(node1, node7Id, 1000);
403-
JedisClusterTestUtil.assertNodeIsUnknown(node2, node7Id, 1000);
404-
JedisClusterTestUtil.assertNodeIsUnknown(node3, node7Id, 1000);
404+
JedisClusterTestUtil.assertNodeIsUnknown(node1, node4Id, 1000);
405+
JedisClusterTestUtil.assertNodeIsUnknown(node2, node4Id, 1000);
406+
JedisClusterTestUtil.assertNodeIsUnknown(node3, node4Id, 1000);
405407

406408
assertEquals(3, node1.clusterNodes().split("\n").length);
407409
assertEquals(3, node2.clusterNodes().split("\n").length);

0 commit comments

Comments
 (0)