This only happens if the message was encoded and then decoded.
Jruby version: jruby 1.7.25
protobuf version: protobuf-3.0.0-beta-4
This fails:
require 'google/protobuf'
Google::Protobuf::DescriptorPool.generated_pool.build do
add_message "TestMessage" do
repeated :repeated_bytes, :bytes, 1
end
end
TestMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup("TestMessage").msgclass
test_message = TestMessage.new(:repeated_bytes => ["hello".encode("ASCII-8BIT")])
reencoded_message = TestMessage.decode(TestMessage.encode(test_message))
reencoded_message.repeated_bytes[0]
Here's the TypeError:
TypeError: Encoding for bytes fields must be "ASCII-8BIT", but was UTF-8 push at com/google/protobuf/jruby/RubyRepeatedField.java:169 [] at com/google/protobuf/jruby/RubyMessage.java:136 method_missing at com/google/protobuf/jruby/RubyMessage.java:223 (root) at test.rb:19
Failure is on the last line. So it looks like it encodes and decodes the message just fine, but fails on access. Have also tested this with byte map fields, resulting in the same behaviour.
This only happens if the message was encoded and then decoded.
Jruby version: jruby 1.7.25
protobuf version: protobuf-3.0.0-beta-4
This fails:
Here's the TypeError:
TypeError: Encoding for bytes fields must be "ASCII-8BIT", but was UTF-8 push at com/google/protobuf/jruby/RubyRepeatedField.java:169 [] at com/google/protobuf/jruby/RubyMessage.java:136 method_missing at com/google/protobuf/jruby/RubyMessage.java:223 (root) at test.rb:19Failure is on the last line. So it looks like it encodes and decodes the message just fine, but fails on access. Have also tested this with byte map fields, resulting in the same behaviour.