From be325cb8fb5a0947e1920ce5ad2441ad546684b9 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 21 Dec 2015 17:24:08 +0100 Subject: [PATCH] Allow state-changing commands on pooled connections #162 --- .../PooledConnectionInvocationHandler.java | 5 --- .../lambdaworks/redis/PoolConnectionTest.java | 36 ------------------- 2 files changed, 41 deletions(-) diff --git a/src/main/java/com/lambdaworks/redis/PooledConnectionInvocationHandler.java b/src/main/java/com/lambdaworks/redis/PooledConnectionInvocationHandler.java index 5c84638f6a..a8e6774c7b 100644 --- a/src/main/java/com/lambdaworks/redis/PooledConnectionInvocationHandler.java +++ b/src/main/java/com/lambdaworks/redis/PooledConnectionInvocationHandler.java @@ -18,7 +18,6 @@ * @since 3.0 */ class PooledConnectionInvocationHandler extends AbstractInvocationHandler { - public static final Set DISABLED_METHODS = ImmutableSet.of("auth", "select", "quit", "setAutoFlushCommands"); private T connection; private final RedisConnectionPool pool; @@ -39,10 +38,6 @@ public Method load(Method key) throws Exception { @Override protected Object handleInvocation(Object proxy, Method method, Object[] args) throws Throwable { - if (DISABLED_METHODS.contains(method.getName())) { - throw new UnsupportedOperationException("Calls to " + method.getName() + " are not supported on pooled connections"); - } - if (connection == null) { throw new RedisException("Connection is deallocated and cannot be used anymore."); } diff --git a/src/test/java/com/lambdaworks/redis/PoolConnectionTest.java b/src/test/java/com/lambdaworks/redis/PoolConnectionTest.java index 33958355f0..55a4a7fb71 100644 --- a/src/test/java/com/lambdaworks/redis/PoolConnectionTest.java +++ b/src/test/java/com/lambdaworks/redis/PoolConnectionTest.java @@ -27,21 +27,6 @@ public void twoConnections() throws Exception { } - @Test - public void setAutoFlushCommandsNotAllowed() throws Exception { - - RedisConnectionPool> pool = client.asyncPool(); - RedisAsyncConnection c1 = pool.allocateConnection(); - try { - c1.setAutoFlushCommands(true); - fail("Missing UnsupportedOperationException"); - } catch (Exception e) { - assertThat(e).isInstanceOf(UnsupportedOperationException.class); - } finally { - pool.close(); - } - } - @Test public void sameConnectionAfterFree() throws Exception { @@ -93,27 +78,6 @@ public void releaseConnectionWithClose() throws Exception { assertThat(pool.getNumActive()).isEqualTo(1); } - @Test(expected = UnsupportedOperationException.class) - public void unsupportedAuthOnPooledConnection() throws Exception { - - RedisConnectionPool> pool = client.pool(); - pool.allocateConnection().auth(""); - } - - @Test(expected = UnsupportedOperationException.class) - public void unsupportedSelectOnPooledConnection() throws Exception { - - RedisConnectionPool> pool = client.pool(); - pool.allocateConnection().select(99); - } - - @Test(expected = UnsupportedOperationException.class) - public void unsupportedQuitOnPooledConnection() throws Exception { - - RedisConnectionPool> pool = client.pool(); - pool.allocateConnection().quit(); - } - @Test public void connectionsClosedAfterPoolClose() throws Exception {