Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #65 from logosity/master

run-jetty :configurator set to run last
  • Loading branch information...
commit f73c6a8f02e7c9fb13ea41c4fc145fec83540ec6 2 parents 95fac93 + e7d7931
@weavejester weavejester authored
View
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))
s))
View
18 ring-jetty-adapter/test/ring/adapter/test/jetty.clj
@@ -1,7 +1,10 @@
(ns ring.adapter.test.jetty
(:use clojure.test
ring.adapter.jetty)
- (: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))))
Please sign in to comment.
Something went wrong with that request. Please try again.