Skip to content

Commit b5de387

Browse files
committed
Restore Session.Cookie class for binary back-compatibility
Fixes gh-38589
1 parent ffdd405 commit b5de387

File tree

2 files changed

+45
-1
lines changed
  • spring-boot-project/spring-boot/src

2 files changed

+45
-1
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/Session.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
import org.springframework.boot.context.properties.NestedConfigurationProperty;
2525
import org.springframework.boot.convert.DurationUnit;
26-
import org.springframework.boot.web.server.Cookie;
2726

2827
/**
2928
* Session properties.
@@ -103,6 +102,15 @@ SessionStoreDirectory getSessionStoreDirectory() {
103102
return this.sessionStoreDirectory;
104103
}
105104

105+
/**
106+
* Session cookie properties. This class is provided only for back-compatibility
107+
* reasons, consider using {@link org.springframework.boot.web.server.Cookie} whever
108+
* possible.
109+
*/
110+
public static class Cookie extends org.springframework.boot.web.server.Cookie {
111+
112+
}
113+
106114
/**
107115
* Available session tracking modes (mirrors
108116
* {@link jakarta.servlet.SessionTrackingMode}.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.web.servlet.server;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static org.assertj.core.api.Assertions.assertThat;
22+
23+
/**
24+
* Tests for {@link Session}.
25+
*
26+
* @author Phillip Webb
27+
*/
28+
class SessionTests {
29+
30+
@Test // gh-38589
31+
void getCookieIsBinaryBackCompatible() throws Exception {
32+
Class<?> returnType = Session.class.getDeclaredMethod("getCookie").getReturnType();
33+
assertThat(returnType.getName()).isEqualTo("org.springframework.boot.web.servlet.server.Session$Cookie");
34+
}
35+
36+
}

0 commit comments

Comments
 (0)