Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
22c22a1c
Commit
22c22a1c
authored
Jan 15, 2018
by
Brian Clozel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move server.session.* to server.servlet.session.*
Closes gh-11589
parent
199d2e30
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
273 additions
and
183 deletions
+273
-183
SessionProperties.java
...amework/boot/autoconfigure/session/SessionProperties.java
+3
-3
ServerProperties.java
...ingframework/boot/autoconfigure/web/ServerProperties.java
+146
-146
DefaultServletWebServerFactoryCustomizer.java
...web/servlet/DefaultServletWebServerFactoryCustomizer.java
+6
-6
additional-spring-configuration-metadata.json
...es/META-INF/additional-spring-configuration-metadata.json
+90
-0
DefaultServletWebServerFactoryCustomizerTests.java
...ervlet/DefaultServletWebServerFactoryCustomizerTests.java
+10
-10
DevToolsPropertyDefaultsPostProcessor.java
...t/devtools/env/DevToolsPropertyDefaultsPostProcessor.java
+1
-1
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+11
-11
spring-boot-features.adoc
...ing-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+4
-4
SampleSessionWebFluxApplicationTests.java
.../sample/session/SampleSessionWebFluxApplicationTests.java
+1
-1
SampleSessionApplicationTests.java
...st/java/sample/session/SampleSessionApplicationTests.java
+1
-1
No files found.
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionProperties.java
View file @
22c22a1c
...
...
@@ -23,7 +23,7 @@ import java.util.Set;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.autoconfigure.web.ServerProperties.Session
;
import
org.springframework.boot.autoconfigure.web.ServerProperties.Se
rvlet.Se
ssion
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.web.servlet.DispatcherType
;
import
org.springframework.session.web.http.SessionRepositoryFilter
;
...
...
@@ -53,7 +53,7 @@ public class SessionProperties {
public
SessionProperties
(
ObjectProvider
<
ServerProperties
>
serverProperties
)
{
ServerProperties
properties
=
serverProperties
.
getIfUnique
();
Session
session
=
(
properties
==
null
?
null
:
properties
.
getSession
());
Session
session
=
(
properties
==
null
?
null
:
properties
.
getSe
rvlet
().
getSe
ssion
());
this
.
timeout
=
(
session
==
null
?
null
:
session
.
getTimeout
());
}
...
...
@@ -68,7 +68,7 @@ public class SessionProperties {
/**
* Return the session timeout.
* @return the session timeout
* @see ServerProperties#getSession()
* @see ServerProperties
.Servlet
#getSession()
*/
public
Duration
getTimeout
()
{
return
this
.
timeout
;
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
View file @
22c22a1c
...
...
@@ -98,8 +98,6 @@ public class ServerProperties {
*/
private
Duration
connectionTimeout
;
private
final
Session
session
=
new
Session
();
@NestedConfigurationProperty
private
Ssl
ssl
;
...
...
@@ -177,10 +175,6 @@ public class ServerProperties {
return
this
.
error
;
}
public
Session
getSession
()
{
return
this
.
session
;
}
public
Ssl
getSsl
()
{
return
this
.
ssl
;
}
...
...
@@ -236,6 +230,8 @@ public class ServerProperties {
@NestedConfigurationProperty
private
final
Jsp
jsp
=
new
Jsp
();
private
final
Session
session
=
new
Session
();
public
String
getContextPath
()
{
return
this
.
contextPath
;
}
...
...
@@ -268,6 +264,10 @@ public class ServerProperties {
return
this
.
jsp
;
}
public
Session
getSession
()
{
return
this
.
session
;
}
public
String
getServletMapping
()
{
if
(
this
.
path
.
equals
(
""
)
||
this
.
path
.
equals
(
"/"
))
{
return
"/"
;
...
...
@@ -319,8 +319,6 @@ public class ServerProperties {
return
result
;
}
}
/**
* Session properties.
*/
...
...
@@ -508,6 +506,8 @@ public class ServerProperties {
}
}
}
/**
* Tomcat properties.
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizer.java
View file @
22c22a1c
...
...
@@ -24,7 +24,7 @@ import javax.servlet.ServletException;
import
javax.servlet.SessionCookieConfig
;
import
org.springframework.boot.autoconfigure.web.ServerProperties
;
import
org.springframework.boot.autoconfigure.web.ServerProperties.Session
;
import
org.springframework.boot.autoconfigure.web.ServerProperties.Se
rvlet.Se
ssion
;
import
org.springframework.boot.autoconfigure.web.embedded.jetty.JettyCustomizer
;
import
org.springframework.boot.autoconfigure.web.embedded.tomcat.TomcatCustomizer
;
import
org.springframework.boot.autoconfigure.web.embedded.undertow.UndertowCustomizer
;
...
...
@@ -89,11 +89,11 @@ public class DefaultServletWebServerFactoryCustomizer
if
(
this
.
serverProperties
.
getDisplayName
()
!=
null
)
{
factory
.
setDisplayName
(
this
.
serverProperties
.
getDisplayName
());
}
if
(
this
.
serverProperties
.
getSession
().
getTimeout
()
!=
null
)
{
factory
.
setSessionTimeout
(
this
.
serverProperties
.
getSession
().
getTimeout
());
if
(
this
.
serverProperties
.
getSe
rvlet
().
getSe
ssion
().
getTimeout
()
!=
null
)
{
factory
.
setSessionTimeout
(
this
.
serverProperties
.
getSe
rvlet
().
getSe
ssion
().
getTimeout
());
}
factory
.
setPersistSession
(
this
.
serverProperties
.
getSession
().
isPersistent
());
factory
.
setSessionStoreDir
(
this
.
serverProperties
.
getSession
().
getStoreDir
());
factory
.
setPersistSession
(
this
.
serverProperties
.
getSe
rvlet
().
getSe
ssion
().
isPersistent
());
factory
.
setSessionStoreDir
(
this
.
serverProperties
.
getSe
rvlet
().
getSe
ssion
().
getStoreDir
());
if
(
this
.
serverProperties
.
getSsl
()
!=
null
)
{
factory
.
setSsl
(
this
.
serverProperties
.
getSsl
());
}
...
...
@@ -121,7 +121,7 @@ public class DefaultServletWebServerFactoryCustomizer
(
UndertowServletWebServerFactory
)
factory
);
}
factory
.
addInitializers
(
new
SessionConfiguringInitializer
(
this
.
serverProperties
.
getSession
()));
new
SessionConfiguringInitializer
(
this
.
serverProperties
.
getSe
rvlet
().
getSe
ssion
()));
factory
.
addInitializers
(
new
InitParameterConfiguringServletContextInitializer
(
this
.
serverProperties
.
getServlet
().
getContextParameters
()));
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json
View file @
22c22a1c
...
...
@@ -1020,6 +1020,96 @@
"level"
:
"error"
}
},
{
"name"
:
"server.session.cookie.comment"
,
"type"
:
"java.lang.String"
,
"description"
:
"Comment for the session cookie."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.cookie.comment"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.cookie.domain"
,
"type"
:
"java.lang.String"
,
"description"
:
"Domain for the session cookie."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.cookie.domain"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.cookie.http-only"
,
"type"
:
"java.lang.Boolean"
,
"description"
:
"
\"
HttpOnly
\"
flag for the session cookie."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.cookie.http-only"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.cookie.max-age"
,
"type"
:
"java.time.Duration"
,
"description"
:
"Maximum age of the session cookie."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.cookie.max-age"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.cookie.name"
,
"type"
:
"java.lang.String"
,
"description"
:
"Session cookie name."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.cookie.name"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.cookie.path"
,
"type"
:
"java.lang.String"
,
"description"
:
"Path of the session cookie."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.cookie.path"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.cookie.secure"
,
"type"
:
"java.lang.Boolean"
,
"description"
:
"
\"
Secure
\"
flag for the session cookie."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.cookie.secure"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.persistent"
,
"type"
:
"java.lang.Boolean"
,
"description"
:
"Whether to persist session data between restarts."
,
"defaultValue"
:
false
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.persistent"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.store-dir"
,
"type"
:
"java.io.File"
,
"description"
:
"Directory used to store session data."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.store-dir"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.timeout"
,
"type"
:
"java.time.Duration"
,
"description"
:
"Session timeout. If a duration suffix is not specified, seconds will be used."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.timeout"
,
"level"
:
"error"
}
},
{
"name"
:
"server.session.tracking-modes"
,
"type"
:
"java.util.Set<org.springframework.boot.autoconfigure.web.ServerProperties.Session.SessionTrackingMode>"
,
"description"
:
"Session tracking modes (one or more of the following:
\"
cookie
\"
,
\"
url
\"
,
\"
ssl
\"
)."
,
"deprecation"
:
{
"replacement"
:
"server.servlet.session.tracking-modes"
,
"level"
:
"error"
}
},
{
"name"
:
"server.undertow.buffers-per-region"
,
"type"
:
"java.lang.Integer"
,
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/DefaultServletWebServerFactoryCustomizerTests.java
View file @
22c22a1c
...
...
@@ -212,15 +212,15 @@ public class DefaultServletWebServerFactoryCustomizerTests {
@Test
public
void
customizeSessionProperties
()
throws
Exception
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"server.session.timeout"
,
"123"
);
map
.
put
(
"server.session.tracking-modes"
,
"cookie,url"
);
map
.
put
(
"server.session.cookie.name"
,
"testname"
);
map
.
put
(
"server.session.cookie.domain"
,
"testdomain"
);
map
.
put
(
"server.session.cookie.path"
,
"/testpath"
);
map
.
put
(
"server.session.cookie.comment"
,
"testcomment"
);
map
.
put
(
"server.session.cookie.http-only"
,
"true"
);
map
.
put
(
"server.session.cookie.secure"
,
"true"
);
map
.
put
(
"server.session.cookie.max-age"
,
"60"
);
map
.
put
(
"server.se
rvlet.se
ssion.timeout"
,
"123"
);
map
.
put
(
"server.se
rvlet.se
ssion.tracking-modes"
,
"cookie,url"
);
map
.
put
(
"server.se
rvlet.se
ssion.cookie.name"
,
"testname"
);
map
.
put
(
"server.se
rvlet.se
ssion.cookie.domain"
,
"testdomain"
);
map
.
put
(
"server.se
rvlet.se
ssion.cookie.path"
,
"/testpath"
);
map
.
put
(
"server.se
rvlet.se
ssion.cookie.comment"
,
"testcomment"
);
map
.
put
(
"server.se
rvlet.se
ssion.cookie.http-only"
,
"true"
);
map
.
put
(
"server.se
rvlet.se
ssion.cookie.secure"
,
"true"
);
map
.
put
(
"server.se
rvlet.se
ssion.cookie.max-age"
,
"60"
);
bindProperties
(
map
);
ConfigurableServletWebServerFactory
factory
=
mock
(
ConfigurableServletWebServerFactory
.
class
);
...
...
@@ -536,7 +536,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
@Test
public
void
sessionStoreDir
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"server.session.store-dir"
,
"myfolder"
);
map
.
put
(
"server.se
rvlet.se
ssion.store-dir"
,
"myfolder"
);
bindProperties
(
map
);
JettyServletWebServerFactory
factory
=
spy
(
new
JettyServletWebServerFactory
());
this
.
customizer
.
customize
(
factory
);
...
...
spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java
View file @
22c22a1c
...
...
@@ -50,7 +50,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
devToolsProperties
.
put
(
"spring.freemarker.cache"
,
"false"
);
devToolsProperties
.
put
(
"spring.groovy.template.cache"
,
"false"
);
devToolsProperties
.
put
(
"spring.mustache.cache"
,
"false"
);
devToolsProperties
.
put
(
"server.session.persistent"
,
"true"
);
devToolsProperties
.
put
(
"server.se
rvlet.se
ssion.persistent"
,
"true"
);
devToolsProperties
.
put
(
"spring.h2.console.enabled"
,
"true"
);
devToolsProperties
.
put
(
"spring.resources.cache.period"
,
"0"
);
devToolsProperties
.
put
(
"spring.resources.chain.cache"
,
"false"
);
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
22c22a1c
...
...
@@ -194,17 +194,17 @@ content into your application. Rather, pick only the properties that you need.
server.servlet.jsp.init-parameters.*= # Init parameters used to configure the JSP servlet.
server.servlet.jsp.registered=true # Whether the JSP servlet is registered.
server.servlet.path=/ # Path of the main dispatcher servlet.
server.session.cookie.comment= # Comment for the session cookie.
server.session.cookie.domain= # Domain for the session cookie.
server.session.cookie.http-only= # "HttpOnly" flag for the session cookie.
server.session.cookie.max-age= # Maximum age of the session cookie. If a duration suffix is not specified, seconds will be used.
server.session.cookie.name= # Session cookie name.
server.session.cookie.path= # Path of the session cookie.
server.session.cookie.secure= # "Secure" flag for the session cookie.
server.session.persistent=false # Whether to persist session data between restarts.
server.session.store-dir= # Directory used to store session data.
server.session.timeout= # Session timeout. If a duration suffix is not specified, seconds will be used.
server.session.tracking-modes= # Session tracking modes (one or more of the following: "cookie", "url", "ssl").
server.se
rvlet.se
ssion.cookie.comment= # Comment for the session cookie.
server.se
rvlet.se
ssion.cookie.domain= # Domain for the session cookie.
server.se
rvlet.se
ssion.cookie.http-only= # "HttpOnly" flag for the session cookie.
server.se
rvlet.se
ssion.cookie.max-age= # Maximum age of the session cookie. If a duration suffix is not specified, seconds will be used.
server.se
rvlet.se
ssion.cookie.name= # Session cookie name.
server.se
rvlet.se
ssion.cookie.path= # Path of the session cookie.
server.se
rvlet.se
ssion.cookie.secure= # "Secure" flag for the session cookie.
server.se
rvlet.se
ssion.persistent=false # Whether to persist session data between restarts.
server.se
rvlet.se
ssion.store-dir= # Directory used to store session data.
server.se
rvlet.se
ssion.timeout= # Session timeout. If a duration suffix is not specified, seconds will be used.
server.se
rvlet.se
ssion.tracking-modes= # Session tracking modes (one or more of the following: "cookie", "url", "ssl").
server.ssl.ciphers= # Supported SSL ciphers.
server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store.
server.ssl.enabled= # Enable SSL support.
...
...
spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
22c22a1c
...
...
@@ -2809,10 +2809,10 @@ Common server settings include:
* Network settings: Listen port for incoming HTTP requests (`server.port`), interface
address to bind to `server.address`, and so on.
* Session settings: Whether the session is persistent (`server.session.persistence`),
session timeout (`server.session.timeout`), location of session data
(`server.session.store-dir`), and session-cookie configuration
(`server.session.cookie.*`).
* Session settings: Whether the session is persistent (`server.se
rvlet.se
ssion.persistence`),
session timeout (`server.se
rvlet.se
ssion.timeout`), location of session data
(`server.se
rvlet.se
ssion.store-dir`), and session-cookie configuration
(`server.se
rvlet.se
ssion.cookie.*`).
* Error management: Location of the error page (`server.error.path`) and so on.
* <<howto.adoc#howto-configure-ssl,SSL>>
* <<howto.adoc#how-to-enable-http-response-compression,HTTP compression>>
...
...
spring-boot-samples/spring-boot-sample-session-webflux/src/test/java/sample/session/SampleSessionWebFluxApplicationTests.java
View file @
22c22a1c
...
...
@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Vedran Pavic
*/
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
(
properties
=
"server.session.timeout:2"
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
@SpringBootTest
(
properties
=
"server.se
rvlet.se
ssion.timeout:2"
,
webEnvironment
=
SpringBootTest
.
WebEnvironment
.
RANDOM_PORT
)
public
class
SampleSessionWebFluxApplicationTests
{
@LocalServerPort
...
...
spring-boot-samples/spring-boot-sample-session/src/test/java/sample/session/SampleSessionApplicationTests.java
View file @
22c22a1c
...
...
@@ -59,7 +59,7 @@ public class SampleSessionApplicationTests {
private
ConfigurableApplicationContext
createContext
()
{
ConfigurableApplicationContext
context
=
new
SpringApplicationBuilder
()
.
sources
(
SampleSessionApplication
.
class
)
.
properties
(
"server.port:0"
,
"server.session.timeout:1"
)
.
properties
(
"server.port:0"
,
"server.se
rvlet.se
ssion.timeout:1"
)
.
initializers
(
new
ServerPortInfoApplicationContextInitializer
()).
run
();
return
context
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment