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: #31
This commit is contained in:
committed by
Thomas Darimont
parent
dea6403c24
commit
5466a70034
@@ -15,6 +15,7 @@ group = 'org.springframework.data'
|
||||
repositories {
|
||||
maven { url "http://repo.springsource.org/libs-snapshot" }
|
||||
maven { url "http://repo.springsource.org/plugins-release" }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: "java"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
slf4jVersion=1.7.5
|
||||
junitVersion=4.10
|
||||
jredisVersion=06052013
|
||||
jedisVersion=2.2.1
|
||||
jedisVersion=2.3.1
|
||||
springVersion=3.2.6.RELEASE
|
||||
log4jVersion=1.2.17
|
||||
version=1.2.0.BUILD-SNAPSHOT
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2011-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,6 +66,7 @@ import redis.clients.util.Pool;
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class JedisConnection implements RedisConnection {
|
||||
|
||||
@@ -1907,7 +1908,7 @@ public class JedisConnection implements RedisConnection {
|
||||
if (isPipelined() || isQueueing()) {
|
||||
throw new UnsupportedOperationException("zAdd of multiple fields not supported " + "in pipeline or transaction");
|
||||
}
|
||||
Map<Double, byte[]> args = zAddArgs(tuples);
|
||||
Map<byte[], Double> args = zAddArgs(tuples);
|
||||
try {
|
||||
return jedis.zadd(key, args);
|
||||
} catch (Exception ex) {
|
||||
@@ -2727,15 +2728,17 @@ public class JedisConnection implements RedisConnection {
|
||||
return args.toArray(new byte[args.size()][]);
|
||||
}
|
||||
|
||||
private Map<Double, byte[]> zAddArgs(Set<Tuple> tuples) {
|
||||
Map<Double, byte[]> args = new HashMap<Double, byte[]>();
|
||||
private Map<byte[], Double> zAddArgs(Set<Tuple> tuples) {
|
||||
|
||||
Map<byte[], Double> args = new HashMap<byte[], Double>();
|
||||
for (Tuple tuple : tuples) {
|
||||
if (args.containsKey(tuple.getScore())) {
|
||||
throw new UnsupportedOperationException("Bulk add of multiple elements with the same score is not supported. "
|
||||
+ "Add the elements individually.");
|
||||
if (args.containsValue(tuple.getScore())) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Bulk add of multiple elements with the same score is not supported. Add the elements individually.");
|
||||
}
|
||||
args.put(tuple.getScore(), tuple.getValue());
|
||||
args.put(tuple.getValue(), tuple.getScore());
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,14 @@
|
||||
|
||||
package org.springframework.data.redis.connection.jedis;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.BlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -32,23 +40,16 @@ import org.springframework.data.redis.connection.StringRedisConnection.StringTup
|
||||
import org.springframework.test.annotation.IfProfileValue;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import redis.clients.jedis.JedisPoolConfig;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.BlockingDeque;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* Integration test of {@link JedisConnection}
|
||||
*
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@@ -95,13 +96,16 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati
|
||||
|
||||
@Test
|
||||
public void testClosePool() {
|
||||
|
||||
JedisPoolConfig config = new JedisPoolConfig();
|
||||
config.setMaxActive(1);
|
||||
config.setMaxWait(1l);
|
||||
config.setMaxTotal(1);
|
||||
config.setMaxIdle(1);
|
||||
|
||||
JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
|
||||
factory2.setHostName(SettingsUtils.getHost());
|
||||
factory2.setPort(SettingsUtils.getPort());
|
||||
factory2.afterPropertiesSet();
|
||||
|
||||
RedisConnection conn2 = factory2.getConnection();
|
||||
conn2.close();
|
||||
factory2.getConnection();
|
||||
@@ -290,13 +294,16 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati
|
||||
|
||||
@Test
|
||||
public void testPoolNPE() {
|
||||
|
||||
JedisPoolConfig config = new JedisPoolConfig();
|
||||
config.setMaxActive(1);
|
||||
config.setMaxTotal(1);
|
||||
|
||||
JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
|
||||
factory2.setUsePool(true);
|
||||
factory2.setHostName(SettingsUtils.getHost());
|
||||
factory2.setPort(SettingsUtils.getPort());
|
||||
factory2.afterPropertiesSet();
|
||||
|
||||
RedisConnection conn = factory2.getConnection();
|
||||
try {
|
||||
conn.get(null);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 the original author or authors.
|
||||
* Copyright 2011-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection.jedis;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -38,6 +38,7 @@ import redis.clients.jedis.JedisPoolConfig;
|
||||
* Integration test of {@link JedisConnection} pipeline functionality
|
||||
*
|
||||
* @author Jennifer Hickey
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration("JedisConnectionIntegrationTests-context.xml")
|
||||
@@ -104,9 +105,10 @@ public class JedisConnectionPipelineIntegrationTests extends AbstractConnectionP
|
||||
@Test
|
||||
// DATAREDIS-213 - Verify connection returns to pool after select
|
||||
public void testClosePoolPipelinedDbSelect() {
|
||||
|
||||
JedisPoolConfig config = new JedisPoolConfig();
|
||||
config.setMaxActive(1);
|
||||
config.setMaxWait(1l);
|
||||
config.setMaxTotal(1);
|
||||
config.setMaxIdle(1);
|
||||
JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
|
||||
factory2.setHostName(SettingsUtils.getHost());
|
||||
factory2.setPort(SettingsUtils.getPort());
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.springframework.oxm.xstream.XStreamMarshaller;
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
|
||||
|
||||
@@ -94,7 +95,7 @@ public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
|
||||
ObjectFactory<byte[]> rawFactory = new RawObjectFactory();
|
||||
|
||||
JedisConnectionFactory jedisConnFactory = new JedisConnectionFactory();
|
||||
jedisConnFactory.getPoolConfig().setMaxActive(defaultPoolConfig.maxActive);
|
||||
jedisConnFactory.getPoolConfig().setMaxTotal(defaultPoolConfig.maxActive);
|
||||
jedisConnFactory.setUsePool(true);
|
||||
jedisConnFactory.setPort(SettingsUtils.getPort());
|
||||
jedisConnFactory.setHostName(SettingsUtils.getHost());
|
||||
|
||||
@@ -20,8 +20,9 @@ Import-Template:
|
||||
org.w3c.dom.*;version="0",
|
||||
javax.xml.transform.*;resolution:="optional";version="0",
|
||||
org.jredis.*;resolution:="optional";version="[1.0.0, 2.0.0)",
|
||||
redis.clients.*;resolution:="optional";version="[2.1.0, 2.1.0]",
|
||||
redis.clients.*;resolution:="optional";version="[2.1.0, 2.3.0)",
|
||||
org.apache.commons.pool.*;resolution:="optional";version="[1.0.0, 3.0.0)",
|
||||
org.apache.commons.pool2.*;resolution:="optional";version="[1.0, 2.0)",
|
||||
org.codehaus.jackson.*;resolution:="optional";version="[1.6, 2.0.0)",
|
||||
com.fasterxml.jackson.*;resolution:="optional";version="[2.0.0, 3.0.0)",
|
||||
org.apache.commons.beanutils.*;resolution:="optional";version=1.8.5,
|
||||
|
||||
Reference in New Issue
Block a user