Accept a port as a number or a string - #4180
Merged
Merged
Conversation
Ports are strings throughout CIDER - cider-select-endpoint insists on it for cider-known-endpoints - but a number is the natural thing to hand to cider-connect from Lisp, and both spellings connect happily. What didn't work was mixing them: the port is stored as it arrived, and the session and REPL matching compares it with equal, so connecting with 51139 and later looking for "51139" found nothing and offered to start a second session for a connection already open. nrepl--normalize-port settles on the string form at the two places a port enters the client, so callers can pass either. The restart-session spec compared ports with = and so quietly depended on them being numbers there; it uses equal now, like the code it exercises.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports are strings throughout CIDER -
cider-select-endpointinsists on it forcider-known-endpoints- but a number is the natural thing to hand tocider-connectfrom Lisp, and both spellings connect happily today.What doesn't work is mixing them. The port is stored exactly as it arrived, and session and REPL matching compares it with
equal, so:and a later lookup with
"51139"finds nothing - CIDER offers to start a second session for a connection it already has, andcider--score-replsscores the right REPL lower than it should.nrepl--normalize-portsettles on the string form at the two points a port enters the client, so callers can pass either and they compare equal afterwards.One test change worth flagging: the restart-session spec compared ports with
=, which only worked because they happened to be numbers on that path. It usesequalnow, like the code it exercises. That spec failing was also what surfaced this - it left a half-connected session behind and took three unrelated specs down with it.