lib/vagrant/util/io.rb in vagrant-unbundled-2.2.7.0 vs lib/vagrant/util/io.rb in vagrant-unbundled-2.2.8.0

- old
+ new

@@ -27,44 +27,24 @@ # in some cases. results = ::IO.select([io], nil, nil, 1.0) break if !results || results[0].empty? # Read! - data << io.readpartial(READ_CHUNK_SIZE).encode("UTF-8", Encoding.default_external) + data << io.readpartial(READ_CHUNK_SIZE).encode( + "UTF-8", Encoding.default_external, + invalid: :replace, + undef: :replace + ) else # Do a simple non-blocking read on the IO object data << io.read_nonblock(READ_CHUNK_SIZE) end - rescue Exception => e - # The catch-all rescue here is to support multiple Ruby versions, - # since we use some Ruby 1.9 specific exceptions. - - breakable = false - if e.is_a?(EOFError) - # An `EOFError` means this IO object is done! - breakable = true - elsif defined?(::IO::WaitReadable) && e.is_a?(::IO::WaitReadable) - # IO::WaitReadable is only available on Ruby 1.9+ - - # An IO::WaitReadable means there may be more IO but this - # IO object is not ready to be read from yet. No problem, - # we read as much as we can, so we break. - breakable = true - elsif e.is_a?(Errno::EAGAIN) - # Otherwise, we just look for the EAGAIN error which should be - # all that IO::WaitReadable does in Ruby 1.9. - breakable = true - end - - # Break out if we're supposed to. Otherwise re-raise the error - # because it is a real problem. - break if breakable - raise + rescue EOFError, Errno::EAGAIN, ::IO::WaitReadable + break end end data end - end end end