@Test
public void testEitherWithObjectReuse() {

	EitherTypeInfo<LongValue, DoubleValue> eitherTypeInfo = new EitherTypeInfo<>(
		ValueTypeInfo.LONG_VALUE_TYPE_INFO, ValueTypeInfo.DOUBLE_VALUE_TYPE_INFO);
	EitherSerializer<LongValue, DoubleValue> eitherSerializer =
		(EitherSerializer<LongValue, DoubleValue>) eitherTypeInfo.createSerializer(new ExecutionConfig());
	LongValue lv = new LongValue();
	DoubleValue dv = new DoubleValue();
	Either<LongValue, DoubleValue> left = Left(lv);
	Either<LongValue, DoubleValue> right = Right(dv);
	// the first copy creates a new instance of Left
	Either<LongValue, DoubleValue> copy0 = eitherSerializer.copy(left, right);
	// then the cross-references are used for future copies
	Either<LongValue, DoubleValue> copy1 = eitherSerializer.copy(right, copy0);
	Either<LongValue, DoubleValue> copy2 = eitherSerializer.copy(left, copy1);
	// validate reference equality
	assertSame(right, copy1);
	assertSame(copy0, copy2);
	// validate reference equality of contained objects
	assertSame(right.right(), copy1.right());
	assertSame(copy0.left(), copy2.left());
}