Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when assigning URI port to default value #135

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

cavalle
Copy link
Contributor

@cavalle cavalle commented Nov 2, 2023

After the changes implemented in #127, connecting to a URI without an explicit port in it (e.g. demo.nats.io) caused a crash:

irb(main):004:0> NATS.connect("demo.nats.io")
/usr/local/bundle/gems/nats-pure-2.3.0/lib/nats/io/client.rb:1828:in `block in process_uri': undefined method `scheme' for "nats://demo.nats.io":String (NoMethodError)
        from /usr/local/bundle/gems/nats-pure-2.3.0/lib/nats/io/client.rb:1818:in `map'
        from /usr/local/bundle/gems/nats-pure-2.3.0/lib/nats/io/client.rb:1818:in `process_uri'
        from /usr/local/bundle/gems/nats-pure-2.3.0/lib/nats/io/client.rb:296:in `parse_and_validate_options'
        from /usr/local/bundle/gems/nats-pure-2.3.0/lib/nats/io/client.rb:265:in `connect'
        from /usr/local/bundle/gems/nats-pure-2.3.0/lib/nats/io/client.rb:52:in `connect'
        from (irb):4:in `<main>'
        from bin/console:7:in `<main>'

This PR fixes that bug.

Copy link
Member

@wallyqs wallyqs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@wallyqs wallyqs merged commit 02d7829 into nats-io:main Nov 20, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants