k.kryo.writeClassAndObject(k.output, object);
return k.output.toBytes();
}
catch (KryoException ke)
{
throw new SerializationException("Failed to serialize.",ke);
}
catch (IllegalArgumentException e) // this happens when requiring registration but serializing an unregistered class
{
throw new SerializationException("Failed to serialize " + SafeString.objectDescription(object) +
" (did you require registration and attempt to serialize an unregistered class?)", e);
}
finally
{
if (k != null)