nats-io / nats-pure.rb

Ruby client for NATS, the cloud native messaging system.
https://nats.io
Apache License 2.0
131 stars 30 forks source link

Fix crash when assigning URI port to default value #135

Closed cavalle closed 11 months ago

cavalle commented 1 year ago

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.