Sha256: 955ae0c7388a23f4bac01ca66204f4cead67639972c2d4679f9a2229f492af13

Contents?: true

Size: 1.12 KB

Versions: 72

Compression:

Stored size: 1.12 KB

Contents

# encoding: utf-8
require "logstash/environment"

if LogStash::Environment.windows?
  require "socket"
  module JRubyBug2558SocketPeerAddrBugFix
    def peeraddr(*args)
      orig_peeraddr(*args).map do |v|
        case v
        when String
          v.force_encoding(Encoding::UTF_8)
        else
          v
        end
      end
    end
  end

  class << Socket
    # Bugfix for jruby #2558
    alias_method :orig_gethostname, :gethostname
    def gethostname
      return orig_gethostname.force_encoding(Encoding::UTF_8)
    end
  end

  class TCPSocket
    alias_method :orig_peeraddr, :peeraddr
    include JRubyBug2558SocketPeerAddrBugFix
  end
  class UDPSocket
    alias_method :orig_peeraddr, :peeraddr
    include JRubyBug2558SocketPeerAddrBugFix
  end
end

if LogStash::Environment.windows?
  # make sure all strings pulled out of ENV are UTF8
  class <<ENV
    alias_method :orig_getter, :[]
    def [](key)
      case value = orig_getter(key)
      when String
        # dup is necessary since force_encoding is destructive
        value.dup.force_encoding(Encoding::UTF_8)
      else
        value
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
logstash-core-6.8.23-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.22-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.21-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.20-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.19-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.18-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.17-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.16-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.15-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.14-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.13-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.12-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.11-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.10-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.9-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.8-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.7-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-7.5.2-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-7.5.1-java lib/logstash/patches/bugfix_jruby_2558.rb
logstash-core-6.8.6-java lib/logstash/patches/bugfix_jruby_2558.rb