diff --git a/src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java b/src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java index f2dfd1024..a56463620 100644 --- a/src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java +++ b/src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java @@ -222,37 +222,38 @@ protected void finishedPayload(byte[] pl) throws IOException { */ protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl) throws IOException { - errorMsg = new byte[errPl.length]; - errorMsg = errPl.clone(); - - StatusCode statusCode = StatusCode.fromBinaryCode(errCode); - - switch (errCode) { - case SUCCESS: - return STATUS_OK; - case ERR_NOT_FOUND: - return new CASOperationStatus(false, new String(errPl), - CASResponse.NOT_FOUND, statusCode); - case ERR_EXISTS: - return new CASOperationStatus(false, new String(errPl), - CASResponse.EXISTS, statusCode); - case ERR_NOT_STORED: - return new CASOperationStatus(false, new String(errPl), - CASResponse.NOT_FOUND, statusCode); - case ERR_2BIG: - case ERR_INTERNAL: - handleError(OperationErrorType.SERVER, new String(errPl)); - case ERR_INVAL: - case ERR_DELTA_BADVAL: - case ERR_NOT_MY_VBUCKET: - case ERR_UNKNOWN_COMMAND: - case ERR_NO_MEM: - case ERR_NOT_SUPPORTED: - case ERR_BUSY: - case ERR_TEMP_FAIL: - return new OperationStatus(false, new String(errPl), statusCode); - default: - return null; + + if(errCode == SUCCESS) { + return STATUS_OK; + } else { + StatusCode statusCode = StatusCode.fromBinaryCode(errCode); + errorMsg = errPl.clone(); + + switch (errCode) { + case ERR_NOT_FOUND: + return new CASOperationStatus(false, new String(errPl), + CASResponse.NOT_FOUND, statusCode); + case ERR_EXISTS: + return new CASOperationStatus(false, new String(errPl), + CASResponse.EXISTS, statusCode); + case ERR_NOT_STORED: + return new CASOperationStatus(false, new String(errPl), + CASResponse.NOT_FOUND, statusCode); + case ERR_2BIG: + case ERR_INTERNAL: + handleError(OperationErrorType.SERVER, new String(errPl)); + case ERR_INVAL: + case ERR_DELTA_BADVAL: + case ERR_NOT_MY_VBUCKET: + case ERR_UNKNOWN_COMMAND: + case ERR_NO_MEM: + case ERR_NOT_SUPPORTED: + case ERR_BUSY: + case ERR_TEMP_FAIL: + return new OperationStatus(false, new String(errPl), statusCode); + default: + return null; + } } }