         "Unexpected default for 'idle-timeout-milliseconds'")
     (is (= acceptor-thread-count (.getAcceptors connector))
         "Unexpected default for 'acceptor-threads' and 'ssl-acceptor-threads'")
-    (is (= selector-thread-count
-           (* 2 (.getSelectorCount (.getSelectorManager connector))))
+    (is (= (selector-thread-count (-> connector .getExecutor .getMaxThreads))
+           (.getSelectorCount (.getSelectorManager connector)))
         "Unexpected default for 'selector-threads' and 'ssl-selector-threads'")))
 
 (defn get-max-threads-for-server

                                 (get-server-thread-pool-queue server)))
        "Unexpected default for 'queue-max-size'")))

(def threads-per-connector
  "The total number of threads needed per attached connector."
  (+ acceptor-thread-count selector-thread-count))

(defn calculate-minimum-required-threads
  "Calculate the minimum number threads that a single Jetty Server instance
  needs.  See: https://github.com/eclipse/jetty.project/blob/jetty-9.4.1.v20170120/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java#L384-L414"
  [connectors]
  (+ 1 (* connectors threads-per-connector)))

(deftest default-min-threads-settings-test
  ;; This test just exists to validate the advice we give for the bare

  ;; at most one encrypted port connector.  Because of this, the test only
  ;; validates the min-threads behavior for a server that has either one or
  ;; two connectors.
  (letfn [(get-server [max-threads connector-count]
            (let [server (Server. (QueuedThreadPool. max-threads))]
              (dotimes [_ connector-count]
                (.addConnector server (ServerConnector. server)))
              server))]
    (dotimes [x 2]
      (let [num-connectors  (inc x)
            required-threads (calculate-minimum-required-threads num-connectors)]
        (testing (str "server with too few threads for " num-connectors " connector(s) "
                      "fail(s) to start with expected error")
          (let [server (-> required-threads
                           dec
                           (get-server num-connectors))]
            (is (thrown-with-msg? IllegalStateException
                                  #"Insufficient configured threads"
                                   (tk-log-testutils/with-test-logging
                                     (.start server))))))
        (testing (str "server with minimum required threads for " num-connectors
                      "connector(s) start(s) successfully")
          (let [server (get-server required-threads num-connectors)]
            (try
              (tk-log-testutils/with-test-logging (.start server))
              (is (.isStarted server))
              (finally
                (.stop server)))))))))
