ring

István Karaszi 2026-04-29T13:45:01.990469Z

Hi there, what is the standard way to set the SO_REUSEADDR socket option using the Jetty adapter?

István Karaszi 2026-04-29T13:46:43.345779Z

Is it by using the :configurator option?

seancorfield 2026-04-29T13:48:40.326629Z

That's the approach we've taken at work for dealing with similar option settings...

István Karaszi 2026-04-29T14:00:31.816929Z

Thank you!

István Karaszi 2026-04-29T14:00:53.322149Z

For future reference, this is what I ended up with:

(defn configurator [^Server server]
  (doseq [^ServerConnector connector (.getConnectors server)]
    (.setReuseAddress connector true)))

👍🏻 1
seancorfield 2026-04-29T14:18:55.385939Z

This is ours, for backward-compatibility in URL parsing(!):

(defn- configure-compliance [^Server server]
  (doseq [^Connector conn (.getConnectors server)]
    (doseq [^ConnectionFactory factory (.getConnectionFactories conn)]
      (try
        (logger/debug "attempting to configure" factory "from" conn)
        (let [^HttpConfiguration config (.getHttpConfiguration factory)]
          (.setUriCompliance config (UriCompliance/from "JETTY_11,ILLEGAL_PATH_CHARACTERS")))
        (catch Exception e
          (logger/error "Error setting URI compliance" (ex-message e)))))))
(Java APIs can be so awful -- the class hierarchy is such that not all connection factories provide .getHttpConfiguration as I recall, so it isn't in a common base class/interface)

👍 1