Skip to content

Commit 5466a70

Browse files
christophstroblThomas Darimont
authored andcommitted
DATAREDIS-260 - Upgrade to jedis 2.3.1.
Jedis upgraded from commons-pool to commons-pool2. Required changes have been introduced. Currently there are both commons-pool and commons-pool2 in class-path which is no problem as those dependencies are optional. Original pull request: spring-projects#31
1 parent dea6403 commit 5466a70

File tree

7 files changed

+42
-27
lines changed

7 files changed

+42
-27
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ group = 'org.springframework.data'
1515
repositories {
1616
maven { url "http://repo.springsource.org/libs-snapshot" }
1717
maven { url "http://repo.springsource.org/plugins-release" }
18+
mavenCentral()
1819
}
1920

2021
apply plugin: "java"

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
slf4jVersion=1.7.5
22
junitVersion=4.10
33
jredisVersion=06052013
4-
jedisVersion=2.2.1
4+
jedisVersion=2.3.1
55
springVersion=3.2.6.RELEASE
66
log4jVersion=1.2.17
77
version=1.2.0.BUILD-SNAPSHOT

src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2013 the original author or authors.
2+
* Copyright 2011-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,6 +66,7 @@
6666
*
6767
* @author Costin Leau
6868
* @author Jennifer Hickey
69+
* @author Christoph Strobl
6970
*/
7071
public class JedisConnection implements RedisConnection {
7172

@@ -1907,7 +1908,7 @@ public Long zAdd(byte[] key, Set<Tuple> tuples) {
19071908
if (isPipelined() || isQueueing()) {
19081909
throw new UnsupportedOperationException("zAdd of multiple fields not supported " + "in pipeline or transaction");
19091910
}
1910-
Map<Double, byte[]> args = zAddArgs(tuples);
1911+
Map<byte[], Double> args = zAddArgs(tuples);
19111912
try {
19121913
return jedis.zadd(key, args);
19131914
} catch (Exception ex) {
@@ -2727,15 +2728,17 @@ private byte[][] bXPopArgs(int timeout, byte[]... keys) {
27272728
return args.toArray(new byte[args.size()][]);
27282729
}
27292730

2730-
private Map<Double, byte[]> zAddArgs(Set<Tuple> tuples) {
2731-
Map<Double, byte[]> args = new HashMap<Double, byte[]>();
2731+
private Map<byte[], Double> zAddArgs(Set<Tuple> tuples) {
2732+
2733+
Map<byte[], Double> args = new HashMap<byte[], Double>();
27322734
for (Tuple tuple : tuples) {
2733-
if (args.containsKey(tuple.getScore())) {
2734-
throw new UnsupportedOperationException("Bulk add of multiple elements with the same score is not supported. "
2735-
+ "Add the elements individually.");
2735+
if (args.containsValue(tuple.getScore())) {
2736+
throw new UnsupportedOperationException(
2737+
"Bulk add of multiple elements with the same score is not supported. Add the elements individually.");
27362738
}
2737-
args.put(tuple.getScore(), tuple.getValue());
2739+
args.put(tuple.getValue(), tuple.getScore());
27382740
}
2741+
27392742
return args;
27402743
}
27412744
}

src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionIntegrationTests.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616

1717
package org.springframework.data.redis.connection.jedis;
1818

19+
import static org.junit.Assert.*;
20+
21+
import java.util.HashSet;
22+
import java.util.Set;
23+
import java.util.concurrent.BlockingDeque;
24+
import java.util.concurrent.LinkedBlockingDeque;
25+
import java.util.concurrent.TimeUnit;
26+
1927
import org.junit.After;
2028
import org.junit.Test;
2129
import org.junit.runner.RunWith;
@@ -32,23 +40,16 @@
3240
import org.springframework.test.annotation.IfProfileValue;
3341
import org.springframework.test.context.ContextConfiguration;
3442
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
35-
import redis.clients.jedis.JedisPoolConfig;
3643

37-
import java.util.HashSet;
38-
import java.util.Set;
39-
import java.util.concurrent.BlockingDeque;
40-
import java.util.concurrent.LinkedBlockingDeque;
41-
import java.util.concurrent.TimeUnit;
42-
43-
import static org.junit.Assert.assertEquals;
44-
import static org.junit.Assert.assertNotNull;
44+
import redis.clients.jedis.JedisPoolConfig;
4545

4646
/**
4747
* Integration test of {@link JedisConnection}
4848
*
4949
* @author Costin Leau
5050
* @author Jennifer Hickey
5151
* @author Thomas Darimont
52+
* @author Christoph Strobl
5253
*/
5354
@RunWith(SpringJUnit4ClassRunner.class)
5455
@ContextConfiguration
@@ -95,13 +96,16 @@ public void testCreateConnectionWithDbFailure() {
9596

9697
@Test
9798
public void testClosePool() {
99+
98100
JedisPoolConfig config = new JedisPoolConfig();
99-
config.setMaxActive(1);
100-
config.setMaxWait(1l);
101+
config.setMaxTotal(1);
102+
config.setMaxIdle(1);
103+
101104
JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
102105
factory2.setHostName(SettingsUtils.getHost());
103106
factory2.setPort(SettingsUtils.getPort());
104107
factory2.afterPropertiesSet();
108+
105109
RedisConnection conn2 = factory2.getConnection();
106110
conn2.close();
107111
factory2.getConnection();
@@ -290,13 +294,16 @@ public void run() {
290294

291295
@Test
292296
public void testPoolNPE() {
297+
293298
JedisPoolConfig config = new JedisPoolConfig();
294-
config.setMaxActive(1);
299+
config.setMaxTotal(1);
300+
295301
JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
296302
factory2.setUsePool(true);
297303
factory2.setHostName(SettingsUtils.getHost());
298304
factory2.setPort(SettingsUtils.getPort());
299305
factory2.afterPropertiesSet();
306+
300307
RedisConnection conn = factory2.getConnection();
301308
try {
302309
conn.get(null);

src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2013 the original author or authors.
2+
* Copyright 2011-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.data.redis.connection.jedis;
1717

18-
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.*;
1919

2020
import java.util.Arrays;
2121
import java.util.List;
@@ -38,6 +38,7 @@
3838
* Integration test of {@link JedisConnection} pipeline functionality
3939
*
4040
* @author Jennifer Hickey
41+
* @author Christoph Strobl
4142
*/
4243
@RunWith(SpringJUnit4ClassRunner.class)
4344
@ContextConfiguration("JedisConnectionIntegrationTests-context.xml")
@@ -104,9 +105,10 @@ public void testUnwatch() throws Exception {
104105
@Test
105106
// DATAREDIS-213 - Verify connection returns to pool after select
106107
public void testClosePoolPipelinedDbSelect() {
108+
107109
JedisPoolConfig config = new JedisPoolConfig();
108-
config.setMaxActive(1);
109-
config.setMaxWait(1l);
110+
config.setMaxTotal(1);
111+
config.setMaxIdle(1);
110112
JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
111113
factory2.setHostName(SettingsUtils.getHost());
112114
factory2.setPort(SettingsUtils.getPort());

src/test/java/org/springframework/data/redis/support/collections/RedisMapTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* @author Costin Leau
4848
* @author Jennifer Hickey
4949
* @author Thomas Darimont
50+
* @author Christoph Strobl
5051
*/
5152
public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
5253

@@ -94,7 +95,7 @@ public static Collection<Object[]> testParams() {
9495
ObjectFactory<byte[]> rawFactory = new RawObjectFactory();
9596

9697
JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory();
97-
jedisConnFactory.getPoolConfig().setMaxActive(defaultPoolConfig.maxActive);
98+
jedisConnFactory.getPoolConfig().setMaxTotal(defaultPoolConfig.maxActive);
9899
jedisConnFactory.setUsePool(true);
99100
jedisConnFactory.setPort(SettingsUtils.getPort());
100101
jedisConnFactory.setHostName(SettingsUtils.getHost());

template.mf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ Import-Template:
2020
org.w3c.dom.*;version="0",
2121
javax.xml.transform.*;resolution:="optional";version="0",
2222
org.jredis.*;resolution:="optional";version="[1.0.0, 2.0.0)",
23-
redis.clients.*;resolution:="optional";version="[2.1.0, 2.1.0]",
23+
redis.clients.*;resolution:="optional";version="[2.1.0, 2.3.0)",
2424
org.apache.commons.pool.*;resolution:="optional";version="[1.0.0, 3.0.0)",
25+
org.apache.commons.pool2.*;resolution:="optional";version="[1.0, 2.0)",
2526
org.codehaus.jackson.*;resolution:="optional";version="[1.6, 2.0.0)",
2627
com.fasterxml.jackson.*;resolution:="optional";version="[2.0.0, 3.0.0)",
2728
org.apache.commons.beanutils.*;resolution:="optional";version=1.8.5,

0 commit comments

Comments
 (0)