Skip to content

Commit

Permalink
SPY-175: Reduce memory use in binary GET
Browse files Browse the repository at this point in the history
Change-Id: I9b90aab0b54a2ae7d2c262d499ff47482b9d6c6c
Reviewed-on: http://review.couchbase.org/38359
Reviewed-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
Tested-by: Michael Nitschinger <michael.nitschinger@couchbase.com>
  • Loading branch information
tootedom authored and Michael Nitschinger committed Jun 17, 2014
1 parent 5911705 commit ca3c8d4
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit ca3c8d4

Please sign in to comment.