Fix UrlPathHelper#shouldRemoveSemicolonContent() (#27303)

The checkReadOnly() method should only be called from
methods that modify properties to prevent modification
of read-only instances.

Fixes #27256
This commit is contained in:
Erik van Paassen
2021-08-22 14:10:25 +02:00
committed by Sam Brannen
parent ab2a861163
commit 10a90d3204
2 changed files with 6 additions and 1 deletions

View File

@@ -132,7 +132,6 @@ public class UrlPathHelper {
* Whether configured to remove ";" (semicolon) content from the request URI.
*/
public boolean shouldRemoveSemicolonContent() {
checkReadOnly();
return this.removeSemicolonContent;
}

View File

@@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.web.testfixture.servlet.MockHttpServletRequest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
/**
* Unit tests for {@link UrlPathHelper}.
@@ -166,6 +167,11 @@ public class UrlPathHelperTests {
assertThat(helper.getLookupPathForRequest(request)).isEqualTo("/welcome.html;c=d");
}
@Test // gh-27303
public void shouldRemoveSemicolonContentWithReadOnlyInstance() {
assertThatCode(UrlPathHelper.defaultInstance::shouldRemoveSemicolonContent).doesNotThrowAnyException();
}
//
// suite of tests root requests for default servlets (SRV 11.2) on Websphere vs Tomcat and other containers