When trace logging is enabled, ConstraintTree calls valueContext.getCurrentValidatedValue() before the validatedValueHandler has been set in getInitializedConstraintValidator. This results in a cast exception when working with Optional and non-Optional fields. The correct behavior is to log the raw `currentValue` instead of trying to unwrap it. Or move the tracing statements until after the correct validatedValueHandler has been assigned.
Originally reported on the dropwizard project
This is similar to HV-1127 but only when trace logging is on.
Tested on 5.4.1, but earlier versions likely effected too.