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.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…
Cancel
Save