// parse the response
ByteBufferInputStream byteBufferInputStream = new ByteBufferInputStream(response);
DatumReader<HandshakeResponse> handshakeReader = new SpecificDatumReader<HandshakeResponse>(HandshakeResponse.class);
HandshakeResponse handshakeResponse = handshakeReader.read(null, DecoderFactory.get().binaryDecoder(byteBufferInputStream, null));
Protocol p = Protocol.parse(handshakeResponse.getServerProtocol());
// finally output the protocol
out.println(p.toString(true));
} finally {