mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '1.1.x'
This commit is contained in:
commit
2186da453f
@ -26,6 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.servlet.ServletContainerInitializer;
|
||||
import javax.servlet.ServletContext;
|
||||
@ -331,7 +332,12 @@ public class TomcatEmbeddedServletContainerFactory extends
|
||||
for (MimeMappings.Mapping mapping : getMimeMappings()) {
|
||||
context.addMimeMapping(mapping.getExtension(), mapping.getMimeType());
|
||||
}
|
||||
context.setSessionTimeout(getSessionTimeout());
|
||||
long timeout = getSessionTimeout();
|
||||
if (timeout > 0) {
|
||||
// Tomcat timeouts are in minutes
|
||||
timeout = Math.max(TimeUnit.SECONDS.toMinutes(timeout), 1L);
|
||||
}
|
||||
context.setSessionTimeout((int) timeout);
|
||||
for (TomcatContextCustomizer customizer : this.tomcatContextCustomizers) {
|
||||
customizer.customize(context);
|
||||
}
|
||||
|
@ -157,14 +157,21 @@ public class TomcatEmbeddedServletContainerFactoryTests extends
|
||||
public void sessionTimeout() throws Exception {
|
||||
TomcatEmbeddedServletContainerFactory factory = getFactory();
|
||||
factory.setSessionTimeout(10);
|
||||
assertTimeout(factory, 10);
|
||||
assertTimeout(factory, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sessionTimeoutInMins() throws Exception {
|
||||
TomcatEmbeddedServletContainerFactory factory = getFactory();
|
||||
factory.setSessionTimeout(1, TimeUnit.MINUTES);
|
||||
assertTimeout(factory, 60);
|
||||
assertTimeout(factory, 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noSessionTimeout() throws Exception {
|
||||
TomcatEmbeddedServletContainerFactory factory = getFactory();
|
||||
factory.setSessionTimeout(0);
|
||||
assertTimeout(factory, -1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user