We're updating the issue view to help you get more done. 

ClassCastException due to unchecked cast in ValidatorImpl

Description

There is an unsafe cast in method collectMetaConstraintsForPath in class ValidatorImpl which might result in ClassCastException under some circumstances. The problem is in the following line:

1 Class<T> castedValueClass = (Class<T>) ( newValue == null ? type : newValue.getClass() );

When newValue is null, the variable type is casted to Class, but it might be of type (for example) ParameterizedTypeImpl since it is initialized like this:

1 Type type = ReflectionHelper.typeOf( m );

I'm not completely sure about conditions, but we are experiencing it from time to time.

Environment

None

Status

Assignee

Unassigned

Reporter

František Řezáč

Labels

Worked in

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Community Help Wanted

None

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Time tracking

8h

Components

Affects versions

4.3.1.Final

Priority

Major