Skip to content

StringIO ignores external encoding on Windows #7367

@jsvd

Description

@jsvd

This happens on JRuby 9.3.8.0 on Windows 2022 Datacenter and Java 17.
I can't seem to reproduce on Mac or Linux.

Expected Behavior

It's expected that new StringIO objects will respect the defined Encoding after it changes.

Actual Behavior

puts RUBY_DESCRIPTION
require 'stringio'
puts Encoding.default_external
puts StringIO.new.external_encoding
ENV["test"] = ""
Encoding.default_external = Encoding::UTF_8
puts StringIO.new.external_encoding
PS C:\> .\jruby-9.3.8.0\bin\jruby C:\logstash-8.4.0\test.rb
jruby 9.3.8.0 (2.6.8) 2022-09-13 98d69c9461 OpenJDK 64-Bit Server VM 17.0.4+8 on 17.0.4+8 +jit [x86_64-mswin32]
IBM437
IBM437
IBM437

While on JRuby 9.2 we can see that the change is respected for new StringIO objects:

PS C:\> .\jruby-9.2.21.0\bin\jruby C:\logstash-8.4.0\test.rb
jruby 9.2.21.0 (2.5.8) 2022-06-27 49e5080a7c OpenJDK 64-Bit Server VM 17.0.4+8 on 17.0.4+8 +jit [mswin32-x86_64]
Windows-1252
Windows-1252
UTF-8

This came from minimizing a reproduction in Logstash, and in within Logstash removing forced jit (threshold=0) the issue went away (but would probably return later once the threshold was hit).

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