Skip to content

BasicSocket#getsockopt does not work with all possible Symbol combinations #3438

@yorickpeterse

Description

@yorickpeterse

The spec at https://github.com/rubysl/rubysl-socket/blob/3950231ce2af8a438deeaa6006fd177356149823/spec/basicsocket/getsockopt_spec.rb currently fails with the following output found at https://gist.github.com/YorickPeterse/d98ec87d068f7237220e

Looking at

protected static SocketOption optionFromArg(IRubyObject _opt) {
SocketOption opt;
if (_opt instanceof RubyString || _opt instanceof RubySymbol) {
opt = SocketOption.valueOf("SO_" + _opt.toString());
} else {
opt = SocketOption.valueOf(RubyNumeric.fix2int(_opt));
}
return opt;
}
protected static SocketLevel levelFromArg(IRubyObject _level) {
SocketLevel level;
if (_level instanceof RubyString || _level instanceof RubySymbol) {
level = SocketLevel.valueOf("SOL_" + _level.toString());
} else {
level = SocketLevel.valueOf(RubyNumeric.fix2int(_level));
}
return level;
}
it seems JRuby assumes the level/optname prefixes are always SOL_/SO_ instead of basing the prefix on the level.

For Rubinius we use the following code to determine the prefixes: https://github.com/rubysl/rubysl-socket/blob/ff68150719df6bedc72ec159fc2e5f166851e800/lib/rubysl/socket/socket_options.rb#L4-L49

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions