From acda0009752a777c621a85d943660b27eef16849 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 12 Apr 2016 10:04:37 +0100 Subject: [PATCH] Polish "Allow Jetty's ThreadPool to be customized" (gh-5324) --- .../JettyEmbeddedServletContainerFactory.java | 3 +-- ...yEmbeddedServletContainerFactoryTests.java | 27 +++++++++---------- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java index df3ca5f65f..4ce669cb1f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java @@ -913,8 +913,7 @@ public class JettyEmbeddedServletContainerFactory @Override public Server createServer(ThreadPool threadPool) { - Server server = new Server(threadPool); - return server; + return new Server(threadPool); } } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java index 33c4608d8f..12f085dfe1 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java @@ -259,26 +259,23 @@ public class JettyEmbeddedServletContainerFactoryTests } @Test - public void threadPool() throws Exception { + public void defaultThreadPool() throws Exception { JettyEmbeddedServletContainerFactory factory = getFactory(); - - ThreadPool threadPool = mock(ThreadPool.class); - factory.setThreadPool(threadPool); - - JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory.getEmbeddedServletContainer(); - assertThat(servletContainer.getServer().getThreadPool()).isSameAs(threadPool); + factory.setThreadPool(null); + assertThat(factory.getThreadPool()).isNull(); + JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory + .getEmbeddedServletContainer(); + assertThat(servletContainer.getServer().getThreadPool()).isNotNull(); } @Test - public void nullThreadPool() throws Exception { + public void customThreadPool() throws Exception { JettyEmbeddedServletContainerFactory factory = getFactory(); - - factory.setThreadPool(null); - - assertThat(factory.getThreadPool()).isNull(); - - JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory.getEmbeddedServletContainer(); - assertThat(servletContainer.getServer().getThreadPool()).isNotNull(); + ThreadPool threadPool = mock(ThreadPool.class); + factory.setThreadPool(threadPool); + JettyEmbeddedServletContainer servletContainer = (JettyEmbeddedServletContainer) factory + .getEmbeddedServletContainer(); + assertThat(servletContainer.getServer().getThreadPool()).isSameAs(threadPool); } @Override