Merge branch '1.1.x'

pull/1438/merge
Phillip Webb 10 years ago
commit 2186da453f

@ -26,6 +26,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletContainerInitializer; import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
@ -331,7 +332,12 @@ public class TomcatEmbeddedServletContainerFactory extends
for (MimeMappings.Mapping mapping : getMimeMappings()) { for (MimeMappings.Mapping mapping : getMimeMappings()) {
context.addMimeMapping(mapping.getExtension(), mapping.getMimeType()); 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) { for (TomcatContextCustomizer customizer : this.tomcatContextCustomizers) {
customizer.customize(context); customizer.customize(context);
} }

@ -157,14 +157,21 @@ public class TomcatEmbeddedServletContainerFactoryTests extends
public void sessionTimeout() throws Exception { public void sessionTimeout() throws Exception {
TomcatEmbeddedServletContainerFactory factory = getFactory(); TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSessionTimeout(10); factory.setSessionTimeout(10);
assertTimeout(factory, 10); assertTimeout(factory, 1);
} }
@Test @Test
public void sessionTimeoutInMins() throws Exception { public void sessionTimeoutInMins() throws Exception {
TomcatEmbeddedServletContainerFactory factory = getFactory(); TomcatEmbeddedServletContainerFactory factory = getFactory();
factory.setSessionTimeout(1, TimeUnit.MINUTES); 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 @Test

Loading…
Cancel
Save