Skip to content


Subversion checkout URL

You can clone with
Download ZIP


run-jetty :configurator set to run last #65

merged 1 commit into from

2 participants


This change allows for replacing the default proxy-handler with a custom handler; the benefit of this (for us) was to allow for logging custom timing and request information from the handler in a way that provides a general solution without adding new configuration options.

The change simply rearranges what's already happening in the run-jetty function to allow the configurator to have the final say on what the configuration will be; it does not otherwise change the function's behavior.

Includes tests that demonstrate that the configurator can change the handler (and that it is the only handler) and the number of threads in the thread pool. Previously these two operations would be overwritten in run-jetty after the configurator was applied.


Looks okay. You don't have to open a new pull request if you want to change your commits, though. It's often preferable to keep to one pull request, just so that there's a trail of why decisions were made.

@weavejester weavejester merged commit f73c6a8 into mmcgrana:master

Cool, glad it looks good. Yeah, I knew it was lame to do that -- but after I squashed them together, the pull request was showing five commits... wasn't sure if that was what you wanted, and didn't want to keep bouncing this thing around. Since I hadn't used the fork for anything else, thought I'd just start over (still pretty new to using github for more than read-only forking)... Thanks James!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 24, 2012
  1. run-jetty configurator applied last. Includes tests.

    Bill Caputo authored
This page is out of date. Refresh to see the latest.
8 ring-jetty-adapter/src/ring/adapter/jetty.clj
@@ -77,12 +77,12 @@
:want or :none (defaults to :none)"
[handler options]
(let [^Server s (create-server (dissoc options :configurator))]
- (when-let [configurator (:configurator options)]
- (configurator s))
(doto s
(.setHandler (proxy-handler handler))
- (.setThreadPool (QueuedThreadPool. (options :max-threads 50)))
- (.start))
+ (.setThreadPool (QueuedThreadPool. (options :max-threads 50))))
+ (when-let [configurator (:configurator options)]
+ (configurator s))
+ (.start s)
(when (:join? options true)
(.join s))
18 ring-jetty-adapter/test/ring/adapter/test/jetty.clj
@@ -1,7 +1,10 @@
(ns ring.adapter.test.jetty
(:use clojure.test
- (:require [clj-http.client :as http]))
+ (:require [clj-http.client :as http])
+ (:import (org.eclipse.jetty.util.thread QueuedThreadPool)
+ (org.eclipse.jetty.server Server Request)
+ (org.eclipse.jetty.server.handler AbstractHandler)))
(defn- hello-world [request]
{:status 200
@@ -30,4 +33,15 @@
:key-password "password"}
(let [response (http/get "https://localhost:4348" {:insecure? true})]
(is (= (:status response) 200))
- (is (= (:body response) "Hello World"))))))
+ (is (= (:body response) "Hello World")))))
+ (testing "configurator set to run last"
+ (let [max-threads 20
+ new-handler (proxy [AbstractHandler] [] (handle [_ ^Request base-request request response]))
+ threadPool (QueuedThreadPool. ({} :max-threads max-threads))
+ configurator (fn [server] (.setThreadPool server threadPool) (.setHandler server new-handler))
+ server (run-jetty hello-world {:join? false :port 4347 :configurator configurator})]
+ (is (= (.getMaxThreads (.getThreadPool server)) max-threads))
+ (is (identical? new-handler (.getHandler server)))
+ (is (= 1 (count (.getHandlers server))))
+ (.stop server))))
Something went wrong with that request. Please try again.