Validation of Java 8 Optional throws ClassCastException

Description

validation of nested Optional object throws class cast exception, if the getter is Optional but field

for example: following code ends with class cast exception:

The problem is that code tries to unwrap that Optional without checking, if the original field value is really Optional (it probably checks only getter)

Workaround exist

if you explicitly change your classes to "do not unwrap", the validation is successfully finished but I would expected that it should work in this way automatically without that annotation.

Environment

None

Status

Assignee

Gunnar Morling

Reporter

Jaroslav Strouhal

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Affects versions

Priority

Major
Configure