diff --git a/src/main/asciidoc/new-features.adoc b/src/main/asciidoc/new-features.adoc
index b7827da4f..2a62d6f05 100644
--- a/src/main/asciidoc/new-features.adoc
+++ b/src/main/asciidoc/new-features.adoc
@@ -12,6 +12,7 @@ New and noteworthy in the latest releases.
* Reactive connection support using https://github.com/lettuce-io/lettuce-core[lettuce-io/lettuce-core].
* Introduce Redis feature-specific interfaces for `RedisConnection`.
* Revised `RedisCache` implementation.
+* Add `SPOP` with count command for Redis 3.2.
[[new-in-1.8.0]]
diff --git a/src/main/java/org/springframework/data/redis/config/RedisListenerContainerParser.java b/src/main/java/org/springframework/data/redis/config/RedisListenerContainerParser.java
index 2c66ca935..0f70998e5 100644
--- a/src/main/java/org/springframework/data/redis/config/RedisListenerContainerParser.java
+++ b/src/main/java/org/springframework/data/redis/config/RedisListenerContainerParser.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2011-2013 the original author or authors.
- *
+ * Copyright 2011-2017 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -38,7 +38,7 @@ import org.w3c.dom.NamedNodeMap;
/**
* Parser for the Redis <listener-container> element.
- *
+ *
* @author Costin Leau
*/
class RedisListenerContainerParser extends AbstractSimpleBeanDefinitionParser {
@@ -73,7 +73,7 @@ class RedisListenerContainerParser extends AbstractSimpleBeanDefinitionParser {
List listDefs = DomUtils.getChildElementsByTagName(element, "listener");
if (!listDefs.isEmpty()) {
- ManagedMap> listeners = new ManagedMap>(
+ ManagedMap> listeners = new ManagedMap<>(
listDefs.size());
for (Element listElement : listDefs) {
Object[] listenerDefinition = parseListener(listElement);
@@ -92,7 +92,7 @@ class RedisListenerContainerParser extends AbstractSimpleBeanDefinitionParser {
/**
* Parses a listener definition. Returns the listener bean reference definition (as the array first entry) and its
* associated topics (also as bean definitions).
- *
+ *
* @param element
* @return
*/
@@ -113,7 +113,7 @@ class RedisListenerContainerParser extends AbstractSimpleBeanDefinitionParser {
}
// assemble topics
- Collection topics = new ArrayList();
+ Collection topics = new ArrayList<>();
// get topic
String xTopics = element.getAttribute("topic");
diff --git a/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
index 9ce3a20b9..d8ea1ade3 100644
--- a/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2014 the original author or authors.
+ * Copyright 2014-2017 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.
@@ -25,12 +25,13 @@ import org.springframework.data.redis.RedisSystemException;
/**
* @author Christoph Strobl
+ * @author Mark Paluch
* @since 1.4
*/
public abstract class AbstractRedisConnection implements DefaultedRedisConnection {
private RedisSentinelConfiguration sentinelConfiguration;
- private ConcurrentHashMap connectionCache = new ConcurrentHashMap();
+ private ConcurrentHashMap connectionCache = new ConcurrentHashMap<>();
/*
* (non-Javadoc)
@@ -73,7 +74,7 @@ public abstract class AbstractRedisConnection implements DefaultedRedisConnectio
/**
* Check if node is active by sending ping.
- *
+ *
* @param node
* @return
*/
@@ -83,7 +84,7 @@ public abstract class AbstractRedisConnection implements DefaultedRedisConnectio
/**
* Get {@link RedisSentinelCommands} connected to given node.
- *
+ *
* @param sentinel
* @return
*/
diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
index 38e80a94f..8fcb49c34 100644
--- a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
+++ b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
@@ -99,7 +99,7 @@ public class ClusterCommandExecutor implements DisposableBean {
public NodeResult executeCommandOnArbitraryNode(ClusterCommandCallback, T> cmd) {
Assert.notNull(cmd, "ClusterCommandCallback must not be null!");
- List nodes = new ArrayList(getClusterTopology().getActiveNodes());
+ List nodes = new ArrayList<>(getClusterTopology().getActiveNodes());
return executeCommandOnSingleNode(cmd, nodes.get(new Random().nextInt(nodes.size())));
}
@@ -133,7 +133,7 @@ public class ClusterCommandExecutor implements DisposableBean {
Assert.notNull(client, "Could not acquire resource for node. Is your cluster info up to date?");
try {
- return new NodeResult(node, cmd.doInCluster(client));
+ return new NodeResult<>(node, cmd.doInCluster(client));
} catch (RuntimeException ex) {
RuntimeException translatedException = convertToDataAccessExeption(ex);
@@ -188,7 +188,7 @@ public class ClusterCommandExecutor implements DisposableBean {
Assert.notNull(callback, "Callback must not be null!");
Assert.notNull(nodes, "Nodes must not be null!");
- List resolvedRedisClusterNodes = new ArrayList();
+ List resolvedRedisClusterNodes = new ArrayList<>();
ClusterTopology topology = topologyProvider.getTopology();
for (final RedisClusterNode node : nodes) {
@@ -199,7 +199,7 @@ public class ClusterCommandExecutor implements DisposableBean {
}
}
- Map>> futures = new LinkedHashMap>>();
+ Map>> futures = new LinkedHashMap<>();
for (final RedisClusterNode node : resolvedRedisClusterNodes) {
futures.put(new NodeExecution(node), executor.submit(() -> executeCommandOnSingleNode(callback, node)));
@@ -212,10 +212,10 @@ public class ClusterCommandExecutor implements DisposableBean {
boolean done = false;
- MulitNodeResult result = new MulitNodeResult();
- Map exceptions = new HashMap();
+ MulitNodeResult result = new MulitNodeResult<>();
+ Map exceptions = new HashMap<>();
- Set saveGuard = new HashSet();
+ Set saveGuard = new HashSet<>();
while (!done) {
done = true;
@@ -255,7 +255,7 @@ public class ClusterCommandExecutor implements DisposableBean {
}
if (!exceptions.isEmpty()) {
- throw new ClusterCommandExecutionFailureException(new ArrayList(exceptions.values()));
+ throw new ClusterCommandExecutionFailureException(new ArrayList<>(exceptions.values()));
}
return result;
}
@@ -270,7 +270,7 @@ public class ClusterCommandExecutor implements DisposableBean {
public MulitNodeResult executeMuliKeyCommand(final MultiKeyClusterCommandCallback cmd,
Iterable keys) {
- Map> nodeKeyMap = new HashMap>();
+ Map> nodeKeyMap = new HashMap<>();
for (byte[] key : keys) {
for (RedisClusterNode node : getClusterTopology().getKeyServingNodes(key)) {
@@ -278,14 +278,14 @@ public class ClusterCommandExecutor implements DisposableBean {
if (nodeKeyMap.containsKey(node)) {
nodeKeyMap.get(node).add(key);
} else {
- Set keySet = new LinkedHashSet();
+ Set keySet = new LinkedHashSet<>();
keySet.add(key);
nodeKeyMap.put(node, keySet);
}
}
}
- Map>> futures = new LinkedHashMap>>();
+ Map>> futures = new LinkedHashMap<>();
for (final Entry> entry : nodeKeyMap.entrySet()) {
@@ -311,7 +311,7 @@ public class ClusterCommandExecutor implements DisposableBean {
Assert.notNull(client, "Could not acquire resource for node. Is your cluster info up to date?");
try {
- return new NodeResult(node, cmd.doInCluster(client, key), key);
+ return new NodeResult<>(node, cmd.doInCluster(client, key), key);
} catch (RuntimeException ex) {
RuntimeException translatedException = convertToDataAccessExeption(ex);
@@ -518,7 +518,7 @@ public class ClusterCommandExecutor implements DisposableBean {
*/
public static class MulitNodeResult {
- List> nodeResults = new ArrayList>();
+ List> nodeResults = new ArrayList<>();
private void add(NodeResult result) {
nodeResults.add(result);
@@ -549,7 +549,7 @@ public class ClusterCommandExecutor implements DisposableBean {
*/
public List resultsAsListSortBy(byte[]... keys) {
- ArrayList> clone = new ArrayList>(nodeResults);
+ ArrayList> clone = new ArrayList<>(nodeResults);
Collections.sort(clone, new ResultByReferenceKeyPositionComperator(keys));
return toList(clone);
@@ -580,7 +580,7 @@ public class ClusterCommandExecutor implements DisposableBean {
private List toList(Collection> source) {
- ArrayList result = new ArrayList();
+ ArrayList result = new ArrayList<>();
for (NodeResult nodeResult : source) {
result.add(nodeResult.getValue());
}
@@ -597,7 +597,7 @@ public class ClusterCommandExecutor implements DisposableBean {
List reference;
public ResultByReferenceKeyPositionComperator(byte[]... keys) {
- reference = new ArrayList(new ByteArraySet(Arrays.asList(keys)));
+ reference = new ArrayList<>(new ByteArraySet(Arrays.asList(keys)));
}
@Override
diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java b/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java
index b9d2a632f..92cf61c93 100644
--- a/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java
+++ b/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java
@@ -25,7 +25,7 @@ import org.springframework.util.StringUtils;
/**
* {@link ClusterTopology} holds snapshot like information about {@link RedisClusterNode}s.
- *
+ *
* @author Christoph Strobl
* @author Mark Paluch
* @since 1.7
@@ -36,7 +36,7 @@ public class ClusterTopology {
/**
* Creates new instance of {@link ClusterTopology}.
- *
+ *
* @param nodes can be {@literal null}.
*/
public ClusterTopology(Set nodes) {
@@ -45,7 +45,7 @@ public class ClusterTopology {
/**
* Get all {@link RedisClusterNode}s.
- *
+ *
* @return never {@literal null}.
*/
public Set getNodes() {
@@ -55,12 +55,12 @@ public class ClusterTopology {
/**
* Get all nodes (master and slave) in cluster where {@code link-state} is {@literal connected} and {@code flags} does
* not contain {@literal fail} or {@literal fail?}.
- *
+ *
* @return never {@literal null}.
*/
public Set getActiveNodes() {
- Set activeNodes = new LinkedHashSet(nodes.size());
+ Set activeNodes = new LinkedHashSet<>(nodes.size());
for (RedisClusterNode node : nodes) {
if (node.isConnected() && !node.isMarkedAsFail()) {
activeNodes.add(node);
@@ -72,12 +72,12 @@ public class ClusterTopology {
/**
* Get all master nodes in cluster where {@code link-state} is {@literal connected} and {@code flags} does not contain
* {@literal fail} or {@literal fail?}.
- *
+ *
* @return never {@literal null}.
*/
public Set getActiveMasterNodes() {
- Set activeMasterNodes = new LinkedHashSet(nodes.size());
+ Set activeMasterNodes = new LinkedHashSet<>(nodes.size());
for (RedisClusterNode node : nodes) {
if (node.isMaster() && node.isConnected() && !node.isMarkedAsFail()) {
activeMasterNodes.add(node);
@@ -88,12 +88,12 @@ public class ClusterTopology {
/**
* Get all master nodes in cluster.
- *
+ *
* @return never {@literal null}.
*/
public Set getMasterNodes() {
- Set masterNodes = new LinkedHashSet(nodes.size());
+ Set masterNodes = new LinkedHashSet<>(nodes.size());
for (RedisClusterNode node : nodes) {
if (node.isMaster()) {
masterNodes.add(node);
@@ -104,13 +104,13 @@ public class ClusterTopology {
/**
* Get the {@link RedisClusterNode}s (master and slave) serving s specific slot.
- *
+ *
* @param slot
* @return never {@literal null}.
*/
public Set getSlotServingNodes(int slot) {
- Set slotServingNodes = new LinkedHashSet(nodes.size());
+ Set slotServingNodes = new LinkedHashSet<>(nodes.size());
for (RedisClusterNode node : nodes) {
if (node.servesSlot(slot)) {
slotServingNodes.add(node);
@@ -121,7 +121,7 @@ public class ClusterTopology {
/**
* Get the {@link RedisClusterNode} that is the current master serving the given key.
- *
+ *
* @param key must not be {@literal null}.
* @return
* @throws ClusterStateFailureException
@@ -142,7 +142,7 @@ public class ClusterTopology {
/**
* Get the {@link RedisClusterNode} matching given {@literal host} and {@literal port}.
- *
+ *
* @param host must not be {@literal null}.
* @param port
* @return
diff --git a/src/main/java/org/springframework/data/redis/connection/DataType.java b/src/main/java/org/springframework/data/redis/connection/DataType.java
index 6dbc2c880..8c0cc644a 100644
--- a/src/main/java/org/springframework/data/redis/connection/DataType.java
+++ b/src/main/java/org/springframework/data/redis/connection/DataType.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2013 the original author or authors.
+ * Copyright 2011-2017 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.
@@ -22,14 +22,14 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* Enumeration of the Redis data types.
- *
+ *
* @author Costin Leau
*/
public enum DataType {
NONE("none"), STRING("string"), LIST("list"), SET("set"), ZSET("zset"), HASH("hash");
- private static final Map codeLookup = new ConcurrentHashMap(6);
+ private static final Map codeLookup = new ConcurrentHashMap<>(6);
static {
for (DataType type : EnumSet.allOf(DataType.class))
@@ -45,7 +45,7 @@ public enum DataType {
/**
* Returns the code associated with the current enum.
- *
+ *
* @return code of this enum
*/
public String code() {
@@ -54,7 +54,7 @@ public enum DataType {
/**
* Utility method for converting an enum code to an actual enum.
- *
+ *
* @param code enum code
* @return actual enum corresponding to the given code
*/
diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java b/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java
index d4303e05c..cb15cf9e7 100644
--- a/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java
+++ b/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java
@@ -1,12 +1,12 @@
/*
- * Copyright 2011-2013 the original author or authors.
- *
+ * Copyright 2011-2017 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required byPattern applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,14 +20,14 @@ import java.util.List;
/**
* Default implementation for {@link SortParameters}.
- *
+ *
* @author Costin Leau
*/
public class DefaultSortParameters implements SortParameters {
private byte[] byPattern;
private Range limit;
- private final List getPattern = new ArrayList(4);
+ private final List getPattern = new ArrayList<>(4);
private Order order;
private Boolean alphabetic;
@@ -40,7 +40,7 @@ public class DefaultSortParameters implements SortParameters {
/**
* Constructs a new DefaultSortParameters instance.
- *
+ *
* @param limit
* @param order
* @param alphabetic
@@ -51,7 +51,7 @@ public class DefaultSortParameters implements SortParameters {
/**
* Constructs a new DefaultSortParameters instance.
- *
+ *
* @param byPattern
* @param limit
* @param getPattern
diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java
index 3285ee2f9..93abfec78 100644
--- a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java
@@ -79,7 +79,7 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
@SuppressWarnings("rawtypes") private Queue pipelineConverters = new LinkedList<>();
@SuppressWarnings("rawtypes") private Queue txConverters = new LinkedList<>();
private boolean deserializePipelineAndTxResults = false;
- private IdentityConverter