private void sendResponse(long requestId, Object value, Class<?> declaredType) throws IOException { DataOutputStream out = newFlusher(); out.writeByte(RESPONSE); out.writeLong(requestId); if (value == null) { out.writeBoolean(false); } else { out.writeBoolean(true); Class<?> clazz = value.getClass(); out.writeUTF(clazz.getName()); Serializer<Object> s = serializerFor(clazz, declaredType); s.serialize(out, value); } out.writeBoolean(false); out.flush(); }