Describe the bug
Session cookie is not issued when the output buffer size exceeds due to including multibyte characters on Spring Boot with Jetty server.
To Reproduce
include Jetty server instead of tomcat
spring boot version: 3.3.1
plugins {
id 'java'
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
}
Expected behavior
When the document size is over 32768 bytes (the default output buffer size on Jetty), the response header should include the Set-Cookie header with the session cookie.
When using Tomcat, this issue does not occur. The difference lies in how buffer length is counted: Tomcat uses char array length, while Jetty uses bytes.
Spring Session counts length in org.springframework.session.web.http.OnCommittedResponseWrapper#trackContentLength
(ref:https://github.com/spring-projects/spring-session/issues/851)
Describe the bug Session cookie is not issued when the output buffer size exceeds due to including multibyte characters on Spring Boot with Jetty server.
To Reproduce
spring boot version: 3.3.1
Gradle dependency:
index.html
<p th:utext="${html}"></p>
OK case:
NG case:
Expected behavior When the document size is over 32768 bytes (the default output buffer size on Jetty), the response header should include the Set-Cookie header with the session cookie.
When using Tomcat, this issue does not occur. The difference lies in how buffer length is counted: Tomcat uses char array length, while Jetty uses bytes. Spring Session counts length in org.springframework.session.web.http.OnCommittedResponseWrapper#trackContentLength (ref:https://github.com/spring-projects/spring-session/issues/851)
Sample
(https://github.com/mjhashimoto/springsessionjettysample/tree/issued20240709)