Skip to content

Commit f71e797

Browse files
committed
Merge branch '4.0.x'
Closes gh-50790
2 parents 2edca39 + 4b542ef commit f71e797

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

module/spring-boot-web-server/src/main/java/org/springframework/boot/web/server/servlet/ServletContextInitializers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private void configureSessionCookie(SessionCookieConfig config) {
9797
map.from(cookie::getHttpOnly).to(config::setHttpOnly);
9898
map.from(cookie::getSecure).to(config::setSecure);
9999
map.from(cookie::getMaxAge).asInt(Duration::getSeconds).to(config::setMaxAge);
100-
map.from(cookie::getPartitioned).to((partitioned) -> config.setAttribute("Partitioned", ""));
100+
map.from(cookie::getPartitioned).whenTrue().to((partitioned) -> config.setAttribute("Partitioned", ""));
101101
}
102102

103103
@Contract("!null -> !null")

module/spring-boot-web-server/src/testFixtures/java/org/springframework/boot/web/server/servlet/AbstractServletWebServerFactoryTests.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,20 @@ void sessionCookiePartitionedAttribute() throws Exception {
899899
(header) -> assertThat(header).isEqualTo("test=test"));
900900
}
901901

902+
@Test
903+
void sessionCookieNotPartitionedAttribute() throws Exception {
904+
ConfigurableServletWebServerFactory factory = getFactory();
905+
factory.getSettings().getSession().getCookie().setPartitioned(false);
906+
factory.addInitializers(new ServletRegistrationBean<>(new CookieServlet(false), "/"));
907+
this.webServer = factory.getWebServer();
908+
this.webServer.start();
909+
ClientHttpResponse clientResponse = getClientResponse(getLocalUrl("/"));
910+
List<String> setCookieHeaders = clientResponse.getHeaders().get("Set-Cookie");
911+
assertThat(setCookieHeaders).satisfiesExactlyInAnyOrder(
912+
(header) -> assertThat(header).startsWith("JSESSIONID=").doesNotContain("; Partitioned"),
913+
(header) -> assertThat(header).isEqualTo("test=test"));
914+
}
915+
902916
@ParameterizedTest
903917
@EnumSource(mode = EnumSource.Mode.EXCLUDE, names = "OMITTED")
904918
void sessionCookieSameSiteAttributeCanBeConfiguredAndOnlyAffectsSessionCookies(SameSite sameSite) throws Exception {
@@ -1226,7 +1240,7 @@ void sessionConfiguration() {
12261240
assertThat(sessionCookieConfig.isHttpOnly()).isTrue();
12271241
assertThat(sessionCookieConfig.isSecure()).isTrue();
12281242
assertThat(sessionCookieConfig.getMaxAge()).isEqualTo(60);
1229-
assertThat(sessionCookieConfig.getAttribute("Partitioned")).isEqualTo("");
1243+
assertThat(sessionCookieConfig.getAttribute("Partitioned")).isNull();
12301244
}
12311245

12321246
@Test

0 commit comments

Comments
 (0)