Skip to content

Commit 3898482

Browse files
committed
Revert commit 0f38c28
The fix is not how the issue needs to be addressed. See gh-34121
1 parent bb7ce21 commit 3898482

File tree

3 files changed

+3
-30
lines changed

3 files changed

+3
-30
lines changed

spring-test/src/test/java/org/springframework/test/web/servlet/samples/spr/ServletRequestDataBinderIntegrationTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import org.junit.jupiter.api.Disabled;
2223
import org.junit.jupiter.api.Test;
2324

2425
import org.springframework.test.context.junit.jupiter.web.SpringJUnitWebConfig;
@@ -56,6 +57,7 @@ void postArray(WebApplicationContext wac) throws Exception {
5657
.andExpect(content().string("valueB"));
5758
}
5859

60+
@Disabled("see gh-34121")
5961
@Test // gh-34121
6062
void postArrayWithEmptyIndex(WebApplicationContext wac) throws Exception {
6163
MockMvc mockMvc = webAppContextSetup(wac).build();
@@ -86,6 +88,7 @@ void postList(WebApplicationContext wac) throws Exception {
8688
.andExpect(content().string("valueB"));
8789
}
8890

91+
@Disabled("see gh-34121")
8992
@Test // gh-34121
9093
void postListWithEmptyIndex(WebApplicationContext wac) throws Exception {
9194
MockMvc mockMvc = webAppContextSetup(wac).build();

spring-web/src/main/java/org/springframework/web/bind/ServletRequestDataBinder.java

-4
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,6 @@ public final Object resolveValue(String name, Class<?> paramType) {
244244
@Nullable
245245
protected Object getRequestParameter(String name, Class<?> type) {
246246
Object value = this.request.getParameterValues(name);
247-
if (value == null && !name.endsWith("[]") &&
248-
(List.class.isAssignableFrom(type) || type.isArray())) {
249-
value = this.request.getParameterValues(name + "[]");
250-
}
251247
return (ObjectUtils.isArray(value) && Array.getLength(value) == 1 ? Array.get(value, 0) : value);
252248
}
253249

spring-web/src/test/java/org/springframework/web/bind/ServletRequestDataBinderTests.java

-26
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,6 @@ void testFieldPrefixCausesFieldResetWithIgnoreUnknownFields() {
9393
assertThat(target.isPostProcessed()).isFalse();
9494
}
9595

96-
@Test
97-
public void testFieldWithArrayIndex() {
98-
TestBean target = new TestBean();
99-
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
100-
binder.setIgnoreUnknownFields(false);
101-
102-
MockHttpServletRequest request = new MockHttpServletRequest();
103-
request.addParameter("stringArray[0]", "ONE");
104-
request.addParameter("stringArray[1]", "TWO");
105-
binder.bind(request);
106-
assertThat(target.getStringArray()).containsExactly("ONE", "TWO");
107-
}
108-
109-
@Test
110-
public void testFieldWithEmptyArrayIndex() {
111-
TestBean target = new TestBean();
112-
ServletRequestDataBinder binder = new ServletRequestDataBinder(target);
113-
binder.setIgnoreUnknownFields(false);
114-
115-
MockHttpServletRequest request = new MockHttpServletRequest();
116-
request.addParameter("stringArray[]", "ONE");
117-
request.addParameter("stringArray[]", "TWO");
118-
binder.bind(request);
119-
assertThat(target.getStringArray()).containsExactly("ONE", "TWO");
120-
}
121-
12296
@Test
12397
void testFieldDefault() {
12498
TestBean target = new TestBean();

0 commit comments

Comments
 (0)