{
// read the input stream into an object. we use the the (apache commons-io) ClassLoaderObjectInputStream
// to read the object because we need to be able to use the same class loader that loaded the class in
// the first place (for example, the RestfulClassLoader).
T object;
try( final ClassLoaderObjectInputStream in = new ClassLoaderObjectInputStream( clazz.getClassLoader(), input ) )
{
object = clazz.cast( in.readObject() );
}
catch( IOException | ClassNotFoundException e )
{
final StringBuilder message = new StringBuilder();
message.append( "Unable to serialize object to output stream:" ).append( Constants.NEW_LINE );