gh-42307
Comment From: philwebb
Thanks @nosan. I think we should also update AbstractServletWebServerFactory.configureSessionCookie and WebSessionIdResolverAutoConfiguration.initializeCookie as well to support the new property. If you have time to update your PR, that would be great. Otherwise we can take it on when we merge.
Comment From: nosan
Thanks for the feedback @philwebb.
I did update my PR but unfortunately, I have not found a straightforward way to update AbstractServletWebServerFactory.configureSessionCookie because jakarta.servlet.SessionCookieConfig does not have a method to set the partitioned property.
The only way as I understand is:
map.from(cookie::getPartitioned)
.to(partitioned -> config.setAttribute(PARTITIONED_ATTRIBUTE_NAME, Boolean.toString(partitioned)));
https://jakarta.ee/specifications/servlet/6.0/apidocs/jakarta.servlet/jakarta/servlet/sessioncookieconfig#setAttribute(java.lang.String,java.lang.String)
Comment From: bclozel
I think this is the only way to support partitioned cookies, see Tomcat for reference:
https://github.com/apache/tomcat/blob/d6e5a088433af43a35293f9a2b19cff359efb79b/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java#L224
Comment From: nosan
@bclozel However, this value could be overridden later through session cookie attributes.
https://github.com/apache/tomcat/blob/d6e5a088433af43a35293f9a2b19cff359efb79b/java/org/apache/catalina/core/ApplicationSessionCookieConfig.java#L229
Comment From: bclozel
@nosan you can raise this as a Tomcat issue if you think this is a bug.
Comment From: nosan
@bclozel
For me, it does not sound like a bug.
As I understood you can set a value for partitioned through Context.setUsePartitioned and then if you specify
sessionCookieConfig.setAttribute(PARTITIONED_ATTRIBUTE_NAME, Boolean.toString(partitioned) this value will be overridden.
// NOTE: The priority order for session cookie configuration is: // 1. Context level configuration // 2. Values from SessionCookieConfig // 3. Defaults
so, this line which I added in this PR should work:
java
map.from(cookie::getPartitioned)
.to(partitioned -> config.setAttribute(PARTITIONED_ATTRIBUTE_NAME, Boolean.toString(partitioned)));
Comment From: bclozel
That was as well my assessment in the first place.
Comment From: mhalbritter
Thanks @nosan !