For some reason if I have class have with some with some optional field and other regular field, valueContext for every field is using OptionalValueUnwrapper to unwrap and thowing cast exception since it is trying cst everyfield into option [validator.isValid(validatedValue,constraintValidatorValue|https://github.com/hibernate/hibernate-validator/blob/e90fea5f5704b1b1f8c657a51fc2f9bde6f8380f/engine/src/main/java/org/hibernate/validator/internal/engine/constraintvalidation/ConstraintTree.java#L446]
public class KafkaProducerFactory extends KafkaClientFactory { static final int DEFAULT_BROKER_PORT = 9092; @NotNull @NotEmpty private String name; @NotEmpty private ImmutableSet<InetSocketAddress> bootstrapServers =of(); private Acknowledgement acknowledgement = ALL; @NotNull @UnwrapValidatedValue private Optional<CompressionType> compression = Optional.of(CompressionType.NONE);
}
I am getting error tired below code to validate Set<ConstraintViolation<T>> invalids = Validation.byProvider(HibernateValidator.class).configure().buildValidatorFactory().getValidator().validate(this);
and
Set<ConstraintViolation<T>> invalids = Validation.buildDefaultValidatorFactory().getValidator().validate(this); |
|