Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 723f2da59934
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5a6d2e6c4dc8
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 22, 2016

  1. Copy the full SHA
    043ea6f View commit details
  2. Merge pull request #4329 from etehtsea/gh-4104-resolv

    Add missing PortUnreachable catch. Fixes #4104
    enebo authored Nov 22, 2016
    Copy the full SHA
    5a6d2e6 View commit details
Showing with 18 additions and 0 deletions.
  1. +3 −0 core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java
  2. +15 −0 spec/regression/GH-4104.rb
3 changes: 3 additions & 0 deletions core/src/main/java/org/jruby/ext/socket/RubyUDPSocket.java
Original file line number Diff line number Diff line change
@@ -511,6 +511,9 @@ public IRubyObject recv(ThreadContext context, IRubyObject length) {
try {
return doReceive(this, runtime, false, RubyNumeric.fix2int(length), null);
}
catch (PortUnreachableException e) {
throw runtime.newErrnoECONNREFUSEDError();
}
catch (IOException e) { // SocketException
throw runtime.newIOErrorFromException(e);
}
15 changes: 15 additions & 0 deletions spec/regression/GH-4104.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rspec'
require 'socket'
require 'resolv'

describe "recv from unreachable destination" do
it "fails with proper error" do
socket = UDPSocket.new(Socket::AF_INET)
socket.do_not_reverse_lookup = true
Resolv::DNS.bind_random_port(socket)
socket.connect('0.0.0.0', 53)
socket.send('some_data', 0)
socket.wait_readable(1)
expect { socket.recv(512) }.to raise_error(Errno::ECONNREFUSED)
end
end