String className = "java=org.apache.avro.ipc.HandshakeRequest";
HandshakeRequest req = new HandshakeRequest();
// set a few values to avoid NPEs
req.clientHash = new MD5();
req.clientProtocol = new Utf8("");
req.serverHash = new MD5();
AvroSpecificSerializer<HandshakeRequest> serializer = new AvroSpecificSerializer<HandshakeRequest>(className);
byte[] bytes = serializer.toBytes(req);
byte[] bytes2 = serializer.toBytes(req);