Skip to content

Commit

Permalink
Allow state-changing commands on pooled connections #162
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Dec 21, 2015
1 parent 9d07076 commit be325cb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
* @since 3.0
*/
class PooledConnectionInvocationHandler<T> extends AbstractInvocationHandler {
public static final Set<String> DISABLED_METHODS = ImmutableSet.of("auth", "select", "quit", "setAutoFlushCommands");

private T connection;
private final RedisConnectionPool<T> pool;
Expand All @@ -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.");
}
Expand Down
36 changes: 0 additions & 36 deletions src/test/java/com/lambdaworks/redis/PoolConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ public void twoConnections() throws Exception {

}

@Test
public void setAutoFlushCommandsNotAllowed() throws Exception {

RedisConnectionPool<RedisAsyncConnection<String, String>> pool = client.asyncPool();
RedisAsyncConnection<String, String> 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 {

Expand Down Expand Up @@ -93,27 +78,6 @@ public void releaseConnectionWithClose() throws Exception {
assertThat(pool.getNumActive()).isEqualTo(1);
}

@Test(expected = UnsupportedOperationException.class)
public void unsupportedAuthOnPooledConnection() throws Exception {

RedisConnectionPool<RedisConnection<String, String>> pool = client.pool();
pool.allocateConnection().auth("");
}

@Test(expected = UnsupportedOperationException.class)
public void unsupportedSelectOnPooledConnection() throws Exception {

RedisConnectionPool<RedisConnection<String, String>> pool = client.pool();
pool.allocateConnection().select(99);
}

@Test(expected = UnsupportedOperationException.class)
public void unsupportedQuitOnPooledConnection() throws Exception {

RedisConnectionPool<RedisConnection<String, String>> pool = client.pool();
pool.allocateConnection().quit();
}

@Test
public void connectionsClosedAfterPoolClose() throws Exception {

Expand Down

0 comments on commit be325cb

Please sign in to comment.