Fix HtmlUnitRequestBuilder merge
Previously invoking HtmlUnitRequestBuilder merge caused the pathInfo of the parent to be corrupted. This could additional invocations with the same parent. This fix ensures that the parent is no longer directly used. Instead, we create a copy of the parent by merging the parent that was passed in with the copy. Fixes SPR-14584
This commit is contained in:
@@ -45,6 +45,8 @@ import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpSession;
|
||||
import org.springframework.test.web.servlet.RequestBuilder;
|
||||
import org.springframework.test.web.servlet.SmartRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
|
||||
import org.springframework.test.web.servlet.request.RequestPostProcessor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -435,7 +437,11 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||
if (parent == null) {
|
||||
return this;
|
||||
}
|
||||
if (parent instanceof RequestBuilder) {
|
||||
if (parent instanceof MockHttpServletRequestBuilder) {
|
||||
MockHttpServletRequestBuilder copiedParent = MockMvcRequestBuilders.get("/");
|
||||
copiedParent.merge(parent);
|
||||
this.parentBuilder = copiedParent;
|
||||
} else if (parent instanceof RequestBuilder) {
|
||||
this.parentBuilder = (RequestBuilder) parent;
|
||||
}
|
||||
if (parent instanceof SmartRequestBuilder) {
|
||||
|
||||
Reference in New Issue
Block a user