diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java index 271a23802..3d894ad86 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java @@ -398,10 +398,10 @@ public class JedisConnection implements RedisConnection { public void bgSave() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.bgsave(); return; @@ -414,10 +414,10 @@ public class JedisConnection implements RedisConnection { public void bgWriteAof() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.bgrewriteaof(); return; @@ -430,10 +430,10 @@ public class JedisConnection implements RedisConnection { public void save() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.save(); return; @@ -446,10 +446,10 @@ public class JedisConnection implements RedisConnection { public List getConfig(String param) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.configGet(param); return null; @@ -462,13 +462,13 @@ public class JedisConnection implements RedisConnection { public Properties info() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } return JedisUtils.info(jedis.info()); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -482,10 +482,10 @@ public class JedisConnection implements RedisConnection { public Long lastSave() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.lastsave(); return null; @@ -498,10 +498,10 @@ public class JedisConnection implements RedisConnection { public void setConfig(String param, String value) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.configSet(param, value); return; @@ -515,10 +515,10 @@ public class JedisConnection implements RedisConnection { public void resetConfigStats() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.configResetStat(); return; @@ -531,13 +531,13 @@ public class JedisConnection implements RedisConnection { public void shutdown() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } jedis.shutdown(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -546,10 +546,10 @@ public class JedisConnection implements RedisConnection { public byte[] echo(byte[] message) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.echo(message); return null; @@ -562,13 +562,13 @@ public class JedisConnection implements RedisConnection { public String ping() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } return jedis.ping(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -738,13 +738,13 @@ public class JedisConnection implements RedisConnection { public byte[] randomKey() { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } return jedis.randomBinaryKey(); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -787,13 +787,13 @@ public class JedisConnection implements RedisConnection { public void select(int dbIndex) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } jedis.select(dbIndex); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1130,13 +1130,13 @@ public class JedisConnection implements RedisConnection { } public Boolean getBit(byte[] key, long offset) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } // compatibility check for Jedis 2.0.0 Object getBit = jedis.getbit(key, offset); // Jedis 2.0 @@ -1152,13 +1152,13 @@ public class JedisConnection implements RedisConnection { public void setBit(byte[] key, long offset, boolean value) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } jedis.setbit(key, offset, JedisUtils.asBit(value)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1167,13 +1167,13 @@ public class JedisConnection implements RedisConnection { public void setRange(byte[] key, byte[] value, long start) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } jedis.setrange(key, start, value); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1980,13 +1980,13 @@ public class JedisConnection implements RedisConnection { public Set zRevRangeByScore(byte[] key, double min, double max, long offset, long count) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } return jedis.zrevrangeByScore(key, max, min, (int) offset, (int) count); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -1995,13 +1995,13 @@ public class JedisConnection implements RedisConnection { public Set zRevRangeByScore(byte[] key, double min, double max) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } return jedis.zrevrangeByScore(key, max, min); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2010,13 +2010,13 @@ public class JedisConnection implements RedisConnection { public Set zRevRangeByScoreWithScores(byte[] key, double min, double max, long offset, long count) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } return JedisUtils.convertJedisTuple(jedis.zrevrangeByScoreWithScores(key, max, min, (int) offset, (int) count)); } catch (Exception ex) { @@ -2026,13 +2026,13 @@ public class JedisConnection implements RedisConnection { public Set zRevRangeByScoreWithScores(byte[] key, double min, double max) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } return JedisUtils.convertJedisTuple(jedis.zrevrangeByScoreWithScores(key, max, min)); } catch (Exception ex) { throw convertJedisAccessException(ex); @@ -2412,10 +2412,10 @@ public class JedisConnection implements RedisConnection { // public Long publish(byte[] channel, byte[] message) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline.publish(channel, message); return null; @@ -2442,15 +2442,14 @@ public class JedisConnection implements RedisConnection { throw new RedisSubscribedConnectionException( "Connection already subscribed; use the connection Subscription to cancel or add new channels"); } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } - BinaryJedisPubSub jedisPubSub = JedisUtils.adaptPubSub(listener); subscription = new JedisSubscription(listener, jedisPubSub, null, patterns); @@ -2468,14 +2467,14 @@ public class JedisConnection implements RedisConnection { "Connection already subscribed; use the connection Subscription to cancel or add new channels"); } - try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } + try { BinaryJedisPubSub jedisPubSub = JedisUtils.adaptPubSub(listener); subscription = new JedisSubscription(listener, jedisPubSub, channels, null); diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java index 018750975..41f7d8200 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java @@ -761,10 +761,10 @@ public class LettuceConnection implements RedisConnection { throw new UnsupportedOperationException("Selecting a new database not supported due to shared connection. " + "Use separate ConnectionFactorys to work with multiple databases"); } + if (isPipelined()) { + throw new UnsupportedOperationException("Lettuce blocks for #select"); + } try { - if (isPipelined()) { - throw new UnsupportedOperationException("Lettuce blocks for #select"); - } getConnection().select(dbIndex); } catch (Exception ex) { throw convertLettuceAccessException(ex); @@ -2146,14 +2146,13 @@ public class LettuceConnection implements RedisConnection { public void pSubscribe(MessageListener listener, byte[]... patterns) { checkSubscription(); + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } - subscription = new LettuceSubscription(listener, switchToPubSub()); subscription.pSubscribe(patterns); } catch (Exception ex) { @@ -2165,10 +2164,10 @@ public class LettuceConnection implements RedisConnection { public void subscribe(MessageListener listener, byte[]... channels) { checkSubscription(); + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isPipelined()) { - throw new UnsupportedOperationException(); - } subscription = new LettuceSubscription(listener, switchToPubSub()); subscription.subscribe(channels); diff --git a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java b/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java index af0ba3411..93a848798 100644 --- a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java @@ -2037,10 +2037,10 @@ public class SrpConnection implements RedisConnection { // public Long publish(byte[] channel, byte[] message) { + if (isQueueing()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } if (isPipelined()) { pipeline(pipeline.publish(channel, message)); return null; @@ -2065,14 +2065,13 @@ public class SrpConnection implements RedisConnection { public void pSubscribe(MessageListener listener, byte[]... patterns) { checkSubscription(); + if (isQueueing()) { + throw new UnsupportedOperationException(); + } + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isQueueing()) { - throw new UnsupportedOperationException(); - } - if (isPipelined()) { - throw new UnsupportedOperationException(); - } - subscription = new SrpSubscription(listener, client); subscription.pSubscribe(patterns); } catch (Exception ex) { @@ -2084,11 +2083,10 @@ public class SrpConnection implements RedisConnection { public void subscribe(MessageListener listener, byte[]... channels) { checkSubscription(); + if (isPipelined()) { + throw new UnsupportedOperationException(); + } try { - if (isPipelined()) { - throw new UnsupportedOperationException(); - } - subscription = new SrpSubscription(listener, client); subscription.subscribe(channels); diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java index 29da1df34..676aed10f 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionPipelineIntegrationTests.java @@ -27,7 +27,6 @@ import org.junit.After; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.connection.AbstractConnectionPipelineIntegrationTests; import org.springframework.data.redis.connection.DefaultStringTuple; import org.springframework.data.redis.connection.StringRedisConnection.StringTuple; @@ -148,7 +147,7 @@ public class JedisConnectionPipelineIntegrationTests extends super.testRestoreTtl(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testBitSet() throws Exception { super.testBitSet(); } @@ -193,42 +192,42 @@ public class JedisConnectionPipelineIntegrationTests extends super.testBitOpNotMultipleSources(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testRandomKey() { super.testRandomKey(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testGetRangeSetRange() { super.testGetRangeSetRange(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testPingPong() throws Exception { super.testPingPong(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testInfo() throws Exception { super.testInfo(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testZRevRangeByScore() { super.testZRevRangeByScore(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testZRevRangeByScoreOffsetCount() { super.testZRevRangeByScoreOffsetCount(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testZRevRangeByScoreWithScores() { super.testZRevRangeByScoreWithScores(); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testZRevRangeByScoreWithScoresOffsetCount() { super.testZRevRangeByScoreWithScoresOffsetCount(); } diff --git a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java index c27f5e5dc..3b6479cbf 100644 --- a/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/jedis/JedisConnectionTransactionIntegrationTests.java @@ -23,7 +23,6 @@ import java.util.List; import org.junit.Ignore; import org.junit.Test; import org.springframework.dao.InvalidDataAccessApiUsageException; -import org.springframework.data.redis.RedisSystemException; import org.springframework.data.redis.RedisVersionUtils; /** @@ -88,12 +87,12 @@ public class JedisConnectionTransactionIntegrationTests extends // Unsupported Ops - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testGetConfig() { connection.getConfig("*"); } - @Test(expected = RedisSystemException.class) + @Test(expected = UnsupportedOperationException.class) public void testEcho() { super.testEcho(); }