Defer decision on BindingResult type until access

Closes gh-24347
This commit is contained in:
Rossen Stoyanchev
2020-05-13 17:24:31 +01:00
parent fe3b36af68
commit 6403a9f10e
2 changed files with 17 additions and 5 deletions

View File

@@ -2050,9 +2050,18 @@ public class DataBinderTests {
assertThatIllegalStateException().isThrownBy(() ->
binder.setMessageCodesResolver(new DefaultMessageCodesResolver()))
.withMessageContaining("DataBinder is already initialized with MessageCodesResolver");
}
@Test // gh-24347
public void overrideBindingResultType() {
TestBean testBean = new TestBean();
DataBinder binder = new DataBinder(testBean, "testBean");
binder.initDirectFieldAccess();
binder.initBeanPropertyAccess();
assertThat(binder.getBindingResult()).isInstanceOf(BeanPropertyBindingResult.class);
}
@SuppressWarnings("unused")
private static class BeanWithIntegerList {