Skip to content
Browse files

Fix QUIT command

Change-Id: If0affd4f3981dd452d9b98d4a7a64382d1f7039f
Reviewed-on: http://review.couchbase.org/13061
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information...
1 parent 471a198 commit cd6f0df710d0bb7e0f6b203f3b74ba656992cc5f @avsej avsej committed with trondn Feb 7, 2012
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/main/java/org/couchbase/mock/memcached/MemcachedConnection.java
View
14 src/main/java/org/couchbase/mock/memcached/MemcachedConnection.java
@@ -19,6 +19,7 @@
import org.couchbase.mock.memcached.protocol.BinaryCommand;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.channels.ClosedChannelException;
import java.util.LinkedList;
import java.util.Queue;
import org.couchbase.mock.memcached.protocol.CommandFactory;
@@ -34,10 +35,10 @@
private final ByteBuffer input;
private final Queue<ByteBuffer> output;
private boolean authenticated;
- private final MemcachedServer server;
+ private boolean closed;
public MemcachedConnection(MemcachedServer server) throws IOException {
- this.server = server;
+ closed = false;
if (server.getBucket().getPassword().length() > 0) {
authenticated = false;
} else {
@@ -50,6 +51,9 @@ public MemcachedConnection(MemcachedServer server) throws IOException {
}
public void step() throws IOException {
+ if (closed) {
+ throw new ClosedChannelException();
+ }
if (input.position() == header.length) {
if (command == null) {
command = CommandFactory.create(input);
@@ -89,7 +93,11 @@ public ByteBuffer getOutputBuffer() {
}
void shutdown() {
- throw new UnsupportedOperationException("Not yet implemented");
+ closed = true;
+ }
+
+ boolean isClosed() {
+ return closed;
}
void setAuthenticated(boolean state) {

0 comments on commit cd6f0df

Please sign in to comment.
Something went wrong with that request. Please try again.