Because of the method of getReaderContext().error() will throw BeanDefinitionParsingException, and the following code will not be executed if an exception is thrown,So I think maybe can remove valid flag and judge.

Comment From: quaff

It depends on ProblemReporter implementation, user implementation may log error instead of throw exception.

Comment From: snicoll

Thanks everyone.

@xichaodong we can't merge a PR in the core container without additional tests and the objections raised are legit.