in folsom/src/main/java/com/spotify/folsom/client/ascii/GetRequest.java [58:90]
public void handle(final AsciiResponse response, final HostAndPort server) throws IOException {
if (response.type == AsciiResponse.Type.EMPTY_LIST) {
succeed(null);
return;
}
if (response.type == AsciiResponse.Type.CLIENT_ERROR) {
MemcacheAuthenticationException exception =
new MemcacheAuthenticationException(
"Authentication required by server. Client not authenticated.");
fail(exception, server);
return;
}
if (!(response instanceof ValueAsciiResponse)) {
throw new IOException("Unexpected response type: " + response.type);
}
List<ValueResponse> values = ((ValueAsciiResponse) response).values;
if (values.size() > 1) {
throw new IOException("Too many responses, expected 1 but got " + values.size());
}
ValueResponse valueResponse = values.get(0);
if (!Arrays.equals(valueResponse.key, key)) {
String message =
"Expected key " + decodeKey(key) + " but got " + decodeKey(valueResponse.key);
throw new IOException(message);
}
succeed(GetResult.success(valueResponse.value, valueResponse.cas, valueResponse.flags));
}