Skip to content
This repository was archived by the owner on Mar 24, 2018. It is now read-only.
This repository was archived by the owner on Mar 24, 2018. It is now read-only.

Message.merge_from fails if target has an unset field of a custom type #16

@aogail

Description

@aogail

I am using ruby_protobuf version 0.4.11 and ruby 2.0.0p247.

Given a proto file:

message Foo {
}

message Bar {
    optional Foo f = 1;
}

Foo.merge_from() will fail if the target's f field is unset:

$ cat foo.rb
require './foo.pb'

b1 = Bar.new
b2 = Bar.new
b2.f = Foo.new
b1.merge_from(b2)

$ ruby foo.rb
/localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/field.rb:622:in `merge_value': undefined method `merge_from' for nil:NilClass (NoMethodError)
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/field.rb:104:in `merge'
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/message.rb:256:in `block in merge_from'
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/message.rb:256:in `each'
    from /localhome/aogail/.rvm/gems/ruby-2.0.0-p247/gems/ruby_protobuf-0.4.11/lib/protobuf/message/message.rb:256:in `merge_from'
    from foo.rb:6:in `<main>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions