in folsom/src/main/java/com/spotify/folsom/client/ascii/MultigetRequest.java [76:115]
public void handle(AsciiResponse response, final HostAndPort server) throws IOException {
final int size = keys.size();
final List<GetResult<byte[]>> result = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
result.add(null);
}
if (response.type == AsciiResponse.Type.EMPTY_LIST) {
succeed(result);
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() > size) {
throw new IOException("Too many responses, expected " + size + " but got " + values.size());
}
int index = -1;
for (final ValueResponse value : values) {
index = findKey(index + 1, value.key);
if (index < 0) {
throw new IOException("Got key in value that was not present in request");
}
result.set(index, GetResult.success(value.value, value.cas, value.flags));
}
succeed(result);
}