Skip to content

Commit 4292f99

Browse files
authored
Merge pull request #444 from Whoops/thread-pool
Add :thread-pool option to run-jetty
2 parents 844a814 + 7ed6c11 commit 4292f99

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

ring-jetty-adapter/src/ring/adapter/jetty.clj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@
148148
pool))
149149

150150
(defn- ^Server create-server [options]
151-
(let [server (Server. (create-threadpool options))]
151+
(let [pool (or (:thread-pool options) (create-threadpool options))
152+
server (Server. pool)]
152153
(when (:http? options true)
153154
(.addConnector server (http-connector server options)))
154155
(when (or (options :ssl?) (options :ssl-port))
@@ -189,6 +190,7 @@
189190
:key-password - the password to the keystore
190191
:keystore-scan-interval - if not nil, the interval in seconds to scan for an
191192
updated keystore
193+
:thread-pool - custom thread pool instance for Jetty to use
192194
:truststore - a truststore to use for SSL connections
193195
:trust-password - the password to the truststore
194196
:max-threads - the maximum number of threads to use (default 50)

ring-jetty-adapter/test/ring/adapter/test/jetty.clj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@
290290
(is (= 1000 (. thread-pool getIdleTimeout)))
291291
(.stop server)))
292292

293+
(testing "providing custom thread-pool"
294+
(let [pool (QueuedThreadPool.)
295+
server (run-jetty hello-world {:port test-port
296+
:join? false
297+
:thread-pool pool})]
298+
(is (identical? pool (.getThreadPool server)))
299+
(.stop server)))
300+
293301
(testing "default character encoding"
294302
(with-server (content-type-handler "text/plain") {:port test-port}
295303
(let [response (http/get test-url)]

0 commit comments

Comments
 (0)