Skip to content

Commit ca3c8d4

Browse files
tootedomMichael Nitschinger
authored andcommitted
SPY-175: Reduce memory use in binary GET
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>
1 parent 5911705 commit ca3c8d4

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

src/main/java/net/spy/memcached/protocol/binary/OperationImpl.java

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -222,37 +222,38 @@ protected void finishedPayload(byte[] pl) throws IOException {
222222
*/
223223
protected OperationStatus getStatusForErrorCode(int errCode, byte[] errPl)
224224
throws IOException {
225-
errorMsg = new byte[errPl.length];
226-
errorMsg = errPl.clone();
227-
228-
StatusCode statusCode = StatusCode.fromBinaryCode(errCode);
229-
230-
switch (errCode) {
231-
case SUCCESS:
232-
return STATUS_OK;
233-
case ERR_NOT_FOUND:
234-
return new CASOperationStatus(false, new String(errPl),
235-
CASResponse.NOT_FOUND, statusCode);
236-
case ERR_EXISTS:
237-
return new CASOperationStatus(false, new String(errPl),
238-
CASResponse.EXISTS, statusCode);
239-
case ERR_NOT_STORED:
240-
return new CASOperationStatus(false, new String(errPl),
241-
CASResponse.NOT_FOUND, statusCode);
242-
case ERR_2BIG:
243-
case ERR_INTERNAL:
244-
handleError(OperationErrorType.SERVER, new String(errPl));
245-
case ERR_INVAL:
246-
case ERR_DELTA_BADVAL:
247-
case ERR_NOT_MY_VBUCKET:
248-
case ERR_UNKNOWN_COMMAND:
249-
case ERR_NO_MEM:
250-
case ERR_NOT_SUPPORTED:
251-
case ERR_BUSY:
252-
case ERR_TEMP_FAIL:
253-
return new OperationStatus(false, new String(errPl), statusCode);
254-
default:
255-
return null;
225+
226+
if(errCode == SUCCESS) {
227+
return STATUS_OK;
228+
} else {
229+
StatusCode statusCode = StatusCode.fromBinaryCode(errCode);
230+
errorMsg = errPl.clone();
231+
232+
switch (errCode) {
233+
case ERR_NOT_FOUND:
234+
return new CASOperationStatus(false, new String(errPl),
235+
CASResponse.NOT_FOUND, statusCode);
236+
case ERR_EXISTS:
237+
return new CASOperationStatus(false, new String(errPl),
238+
CASResponse.EXISTS, statusCode);
239+
case ERR_NOT_STORED:
240+
return new CASOperationStatus(false, new String(errPl),
241+
CASResponse.NOT_FOUND, statusCode);
242+
case ERR_2BIG:
243+
case ERR_INTERNAL:
244+
handleError(OperationErrorType.SERVER, new String(errPl));
245+
case ERR_INVAL:
246+
case ERR_DELTA_BADVAL:
247+
case ERR_NOT_MY_VBUCKET:
248+
case ERR_UNKNOWN_COMMAND:
249+
case ERR_NO_MEM:
250+
case ERR_NOT_SUPPORTED:
251+
case ERR_BUSY:
252+
case ERR_TEMP_FAIL:
253+
return new OperationStatus(false, new String(errPl), statusCode);
254+
default:
255+
return null;
256+
}
256257
}
257258
}
258259

0 commit comments

Comments
 (0)