Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-60821] - Let Jetty configure its own defaults #197

Merged
merged 3 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/main/java/org/jvnet/hudson/test/HudsonTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.security.Password;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
Expand Down Expand Up @@ -504,13 +505,9 @@ public void setPluginManager(PluginManager pluginManager) {
* that we need for testing.
*/
protected ServletContext createWebServer() throws Exception {
server = new Server(new ThreadPoolImpl(new ThreadPoolExecutor(10, 10, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(),new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("Jetty Thread Pool");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can not apply naming with the QueuedThreadPool without also specifiying the number of threads etc.

return t;
}
})));
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setName("Jetty (HudsonTestCase)");
server = new Server(qtp);

explodedWarDir = WarExploder.getExplodedDir();
WebAppContext context = new WebAppContext(explodedWarDir.getPath(), contextPath);
Expand All @@ -522,7 +519,7 @@ public Thread newThread(Runnable r) {
context.setMimeTypes(MIME_TYPES);
context.getSecurityHandler().setLoginService(configureUserRealm());

ServerConnector connector = new ServerConnector(server, 1, 1);
ServerConnector connector = new ServerConnector(server);

HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
// use a bigger buffer as Stapler traces can get pretty large on deeply nested URL
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/jvnet/hudson/test/JavaNetReverseProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;

import org.eclipse.jetty.util.thread.QueuedThreadPool;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
Expand All @@ -34,16 +34,17 @@ public class JavaNetReverseProxy extends HttpServlet {
public JavaNetReverseProxy(File cacheFolder) throws Exception {
this.cacheFolder = cacheFolder;
cacheFolder.mkdirs();

server = new Server();
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setName("Jetty (JavaNetReverseProxy)");
server = new Server(qtp);

ContextHandlerCollection contexts = new ContextHandlerCollection();
server.setHandler(contexts);

ServletContextHandler root = new ServletContextHandler(contexts, "/", ServletContextHandler.SESSIONS);
root.addServlet(new ServletHolder(this), "/");

ServerConnector connector = new ServerConnector(server, 1, 1);
ServerConnector connector = new ServerConnector(server);
server.addConnector(connector);
server.start();

Expand Down
13 changes: 5 additions & 8 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.util.security.Password;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.WebXmlConfiguration;
Expand Down Expand Up @@ -733,13 +734,9 @@ public static ImmutablePair<Server, ServletContext> _createWebServer(String cont
ClassLoader classLoader, int localPort,
Supplier<LoginService> loginServiceSupplier)
throws Exception {
Server server = new Server(new ThreadPoolImpl(new ThreadPoolExecutor(10, 10, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("Jetty Thread Pool");
return t;
}
})));
QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setName("Jetty (JenkinsRule)");
Server server = new Server(qtp);

WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
context.setClassLoader(classLoader);
Expand All @@ -750,7 +747,7 @@ public Thread newThread(Runnable r) {
context.getSecurityHandler().setLoginService(loginServiceSupplier.get());
context.setResourceBase(WarExploder.getExplodedDir().getPath());

ServerConnector connector = new ServerConnector(server, 1, 1);
ServerConnector connector = new ServerConnector(server);
HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
// use a bigger buffer as Stapler traces can get pretty large on deeply nested URL
config.setRequestHeaderSize(12 * 1024);
Expand Down