Skip to content

Commit

Permalink
Add and populate :host and :socket keys on nrepl.server.Server
Browse files Browse the repository at this point in the history
This fixes an issue that occurs when using the `--interactive` option in
concert with `--socket PATH`. Since the Server object has no :socket
key, nrepl.cmdline/interactive-repl won't recognize that it should
connect to the socket and will exit with an error message.

This also ensures that consumers of the record can obtain the passed-in
host value.
  • Loading branch information
chancerussell committed Feb 8, 2024
1 parent df07718 commit d625f01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -5,6 +5,7 @@
### Bugs fixed

* [#307](https://github.com/nrepl/nrepl/pull/307): Fix issue where TLS accept loop could sometimes exit prematurely. This caused tests to hang sometimes.
* [#311](https://github.com/nrepl/nrepl/pull/311): Make `--interactive` option work when starting a server on a filesystem socket with `--socket PATH`.

### Changes

Expand Down
4 changes: 3 additions & 1 deletion src/clojure/nrepl/server.clj
Expand Up @@ -158,7 +158,7 @@
(binding [dynamic-loader/*state* state]
((:handler @state) msg)))))

(defrecord Server [server-socket port open-transports transport greeting handler]
(defrecord Server [server-socket host port socket open-transports transport greeting handler]
java.io.Closeable
(close [this] (stop-server this)))

Expand Down Expand Up @@ -211,7 +211,9 @@
:else
(inet-socket bind port))
server (Server. ss
(when-not socket bind)
(when-not socket (.getLocalPort ^java.net.ServerSocket ss))
socket
(atom #{})
transport-fn
greeting-fn
Expand Down

0 comments on commit d625f01

Please sign in to comment.