Deprecate setDisallowedFields in DataBinder

Closes gh-36816
Signed-off-by: Juhwan Lee <jhan0121@gmail.com>
This commit is contained in:
jhan0121
2026-07-29 16:17:09 +03:00
committed by rstoyanchev
parent 3f632382d6
commit 4bcae5305d
6 changed files with 29 additions and 3 deletions
@@ -329,6 +329,7 @@ class WebRequestDataBinderTests {
}
@Test
@SuppressWarnings("removal")
void shouldNotTriggerBindingWhenFieldIsDisallowed() {
TestBean tb = new TestBean();
@@ -363,6 +364,7 @@ class WebRequestDataBinderTests {
@ParameterizedTest
@ValueSource(strings = { "stringArray*", "stringArray[]" })
@SuppressWarnings("removal")
void shouldNotTriggerBindingWhenFieldIsDisallowedWithEmptyArrayIndex(String disallowedField) {
TestBean tb = new TestBean();
@@ -398,6 +400,7 @@ class WebRequestDataBinderTests {
@ParameterizedTest
@ValueSource(strings = { "someMap*", "someMap[*]", "someMap[key1]" })
@SuppressWarnings("removal")
void shouldNotTriggerAutoGrowWhenFieldIsDisallowed(String disallowedField) {
TestBean tb = new TestBean();
tb.setSomeMap(null);
@@ -56,6 +56,7 @@ class InitBinderDataBinderFactoryTests {
@Test
@SuppressWarnings("removal")
void createBinder() throws Exception {
WebDataBinderFactory factory = createFactory("initBinder", WebDataBinder.class);
WebDataBinder dataBinder = factory.createBinder(this.webRequest, null, null);
@@ -76,6 +77,7 @@ class InitBinderDataBinderFactoryTests {
}
@Test
@SuppressWarnings("removal")
void createBinderWithAttrName() throws Exception {
WebDataBinderFactory factory = createFactory("initBinderWithAttributeName", WebDataBinder.class);
WebDataBinder dataBinder = factory.createBinder(this.webRequest, null, "foo");
@@ -85,6 +87,7 @@ class InitBinderDataBinderFactoryTests {
}
@Test
@SuppressWarnings("removal")
void createBinderWithAttrNameNoMatch() throws Exception {
WebDataBinderFactory factory = createFactory("initBinderWithAttributeName", WebDataBinder.class);
WebDataBinder dataBinder = factory.createBinder(this.webRequest, null, "invalidName");
@@ -93,6 +96,7 @@ class InitBinderDataBinderFactoryTests {
}
@Test
@SuppressWarnings("removal")
void createBinderNullAttrName() throws Exception {
WebDataBinderFactory factory = createFactory("initBinderWithAttributeName", WebDataBinder.class);
WebDataBinder dataBinder = factory.createBinder(this.webRequest, null, null);
@@ -108,6 +112,7 @@ class InitBinderDataBinderFactoryTests {
}
@Test
@SuppressWarnings("removal")
void createBinderTypeConversion() throws Exception {
this.webRequest.getNativeRequest(MockHttpServletRequest.class).setParameter("requestParam", "22");
this.argumentResolvers.addResolver(new RequestParamMethodArgumentResolver(null, false));
@@ -138,11 +143,13 @@ class InitBinderDataBinderFactoryTests {
private static class InitBinderHandler {
@InitBinder
@SuppressWarnings("removal")
public void initBinder(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
@InitBinder(value="foo")
@SuppressWarnings("removal")
public void initBinderWithAttributeName(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
@@ -153,6 +160,7 @@ class InitBinderDataBinderFactoryTests {
}
@InitBinder
@SuppressWarnings("removal")
public void initBinderTypeConversion(WebDataBinder dataBinder, @RequestParam int requestParam) {
dataBinder.setDisallowedFields("requestParam-" + requestParam);
}