}
}
protected List<ByteBuffer> prepareResponse(Object value, Status status,
String errorClass, String error) {
ByteBufferOutputStream buf = new ByteBufferOutputStream();
DataOutputStream out = new DataOutputStream(buf);
try {
RpcResponseHeader.Builder builder = RpcResponseHeader.newBuilder();
builder.setStatus(status);
builder.build().writeDelimitedTo(out);
if (error != null) {
RpcException.Builder b = RpcException.newBuilder();
b.setExceptionName(errorClass);
b.setStackTrace(error);
b.build().writeDelimitedTo(out);
} else {
if (value != null) {
((Message) value).writeDelimitedTo(out);
}
}
} catch (IOException e) {
LOG.warn("Exception while creating response " + e);
}
return buf.getBufferList();
}