SIGN IN SIGN UP

Protocol Buffers - Google's data interchange format

0 0 35 C++

Fix jruby encoding in new thread (#12919)

In jruby `runtime.evalScriptlet('Encoding::UTF_8')` can be broken under a newly created thread, which can cause protobuf encoding to fail. For example: https://github.com/ntkme/sass-embedded-host-ruby/actions/runs/5108602231/jobs/9182569583#step:5:544

It real issue seems to be in jruby itself. A bug report with minimal reproduction has been filed at https://github.com/jruby/jruby/issues/7820

This PR fixes the problem by effectively replacing `runtime.evalScriptlet('Encoding::UTF_8')` with `runtime.getEncodingService().convertEncodingToRubyEncoding(org.jcodings.specific.UTF8Encoding.INSTANCE)`, which works on all threads.

Closes #12919

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12919 from ntkme:fix-jruby-encoding 345680ea91e1cb73f66f023a50d4a4c30f170071
PiperOrigin-RevId: 536498846
なつき committed
6609bea792af9624f460dad0213bb47fd1ccf623
Parent: 79f0575
Committed by Copybara-Service <copybara-worker@google.com> on 5/30/2023, 8:56:39 PM