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

Socket.pack_sockaddr_in fails for nil port (MRI doesn't) #3156

Closed
grddev opened this issue Jul 21, 2015 · 0 comments · Fixed by #3219
Closed

Socket.pack_sockaddr_in fails for nil port (MRI doesn't) #3156

grddev opened this issue Jul 21, 2015 · 0 comments · Fixed by #3219

Comments

@grddev
Copy link
Contributor

grddev commented Jul 21, 2015

JRuby raises a TypeError when the port is nil, whereas MRI treats nil the same way as zero.

> ruby-2.2.2 -rsocket -e 'p Socket.pack_sockaddr_in(nil, "127.0.0.1")'
"\x10\x02\x00\x00\x7F\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00"

> jruby-1.7.19 -rsocket -e 'p Socket.pack_sockaddr_in(nil, "127.0.0.1")'
TypeError: no implicit conversion from nil to integer
  pack_sockaddr_in at org/jruby/ext/socket/RubySocket.java:272
            (root) at -e:1

I'm using 1.7.19 in my example, but it seems the code in SocketUtils hasn't changed since 2012 in master, so I'm guessing it still applies to both 1.7.x and 9k. See https://github.com/jruby/jruby/blame/26d0b20ca324d082468bbcbc9d71709b142aa77b/core/src/main/java/org/jruby/ext/socket/SocketUtils.java#L131-L140

reuben-sutton added a commit to reuben-sutton/jruby that referenced this issue Aug 3, 2015
Ensure compatability with MRI Ruby

closes jruby#3156
@enebo enebo added this to the JRuby 1.7.22 milestone Aug 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants