Affects: 6.0.14


The type descriptors of java.util.Optional<java.lang.Integer> and java.util.Optional<java.lang.String> are considered equal.

    var r1 = ResolvableType.forClassWithGenerics(Optional.class, Integer.class);
    var r2 = ResolvableType.forClassWithGenerics(Optional.class, String.class);

    var t1 = new TypeDescriptor(r1, null, null);
    var t2 = new TypeDescriptor(r2, null, null);

    assertNotEquals(r1, r2); // passes
    assertNotEquals(t1, t2); // fails

I encountered it in context of GenericConversionService caching. Let's say we have two distinct ConditionalGenericConverter as follows (1) sourceType=Pojo, targetType=Optional<Integer> (2) sourceType=Pojo, targetType=Optional<String>

The GenericConversionService service is able to cache only one of converters mentioned above. Let's assume we successfully used (1) converter. When we want to convert using (2) converter the GenericConversionService uses (1) converter which causes class cast exception later.