Upgrade to Tomcat 11.0

This commit upgrades the baseline to Tomcat 11.0 and adapts to the
following behavior changes in Tomcat:

* the MimeHeaders#clear method has been removed
* expired cookies do not set "Max-Age=0" anymore
* responses to HEAD requests do not write the "Content-Length" header
  anymore.

Closes gh-33916
This commit is contained in:
Brian Clozel 2024-11-19 18:07:22 +01:00
parent c28cbfd582
commit 4b3e192ca1
4 changed files with 9 additions and 9 deletions

View File

@ -103,10 +103,10 @@ dependencies {
api("org.apache.httpcomponents.client5:httpclient5:5.4.1")
api("org.apache.httpcomponents.core5:httpcore5-reactive:5.3.1")
api("org.apache.poi:poi-ooxml:5.2.5")
api("org.apache.tomcat.embed:tomcat-embed-core:10.1.28")
api("org.apache.tomcat.embed:tomcat-embed-websocket:10.1.28")
api("org.apache.tomcat:tomcat-util:10.1.28")
api("org.apache.tomcat:tomcat-websocket:10.1.28")
api("org.apache.tomcat.embed:tomcat-embed-core:11.0.1")
api("org.apache.tomcat.embed:tomcat-embed-websocket:11.0.1")
api("org.apache.tomcat:tomcat-util:11.0.1")
api("org.apache.tomcat:tomcat-websocket:11.0.1")
api("org.aspectj:aspectjrt:1.9.22.1")
api("org.aspectj:aspectjtools:1.9.22.1")
api("org.aspectj:aspectjweaver:1.9.22.1")

View File

@ -161,10 +161,11 @@ class TomcatHeadersAdapter implements MultiValueMap<String, String> {
map.forEach(this::put);
}
@SuppressWarnings("deprecation") // on Tomcat 10.1.16+
@Override
public void clear() {
this.headers.clear();
for (int i = 0 ; i < this.headers.size(); i++) {
this.headers.removeHeader(i);
}
}
@Override

View File

@ -141,7 +141,7 @@ class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTests {
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
String value = response.getHeaders().getFirst("Set-Cookie");
assertThat(value).isNotNull();
assertThat(value).as("Actual value: " + value).contains("Max-Age=0");
assertThat(value).as("Actual value: " + value).containsAnyOf("Expires=Thu, 01 Jan 1970", "Max-Age=0");
}
@ParameterizedHttpServerTest
@ -189,7 +189,7 @@ class WebSessionIntegrationTests extends AbstractHttpHandlerIntegrationTests {
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
String value = response.getHeaders().getFirst("Set-Cookie");
assertThat(value).isNotNull();
assertThat(value).as("Actual value: " + value).contains("Max-Age=0");
assertThat(value).as("Actual value: " + value).containsAnyOf("Expires=Thu, 01 Jan 1970", "Max-Age=0");
}
private String extractSessionId(HttpHeaders headers) {

View File

@ -93,7 +93,6 @@ class RequestMappingIntegrationTests extends AbstractRequestMappingIntegrationTe
HttpHeaders headers = getRestTemplate().headForHeaders(url);
String contentType = headers.getFirst("Content-Type");
assertThat(contentType).isNotNull();
assertThat(headers.getContentLength()).isEqualTo(3);
}
@ParameterizedHttpServerTest