diff --git a/src/main/java/net/spy/memcached/MemcachedConnection.java b/src/main/java/net/spy/memcached/MemcachedConnection.java index 9fc817b39..09f7c49ce 100644 --- a/src/main/java/net/spy/memcached/MemcachedConnection.java +++ b/src/main/java/net/spy/memcached/MemcachedConnection.java @@ -473,8 +473,9 @@ private void handleOperationalTasks() throws IOException { } if (!retryOps.isEmpty()) { - redistributeOperations(new ArrayList(retryOps)); + ArrayList operations = new ArrayList(retryOps); retryOps.clear(); + redistributeOperations(operations); } handleShutdownQueue(); @@ -1042,7 +1043,7 @@ public void redistributeOperation(Operation op) { // The operation gets redistributed but has never been actually written, // it we just straight re-add it without cloning. - if (op.getState() == OperationState.WRITE_QUEUED) { + if (op.getState() == OperationState.WRITE_QUEUED && op.getHandlingNode() != null) { addOperation(op.getHandlingNode(), op); return; } @@ -1257,6 +1258,10 @@ public void insertOperation(final MemcachedNode node, final Operation o) { * @param o the operation to add. */ protected void addOperation(final MemcachedNode node, final Operation o) { + if (!node.isAuthenticated()) { + retryOperation(o); + return; + } o.setHandlingNode(node); o.initialize(); node.addOp(o);