Status: New
Owner: ken...@google.com
Labels: Type-Defect Priority-Medium

New issue 249 by osfan6313: Default values are not assumed to be filled in.
http://code.google.com/p/protobuf/issues/detail?id=249

What steps will reproduce the problem?
1. Create a protocol buffer file with a required field that has a default value. 2. Compile this protocol buffer, and attempt to make a new protocol buffer via the builder, i.e. newBuilder().build() 3. A runtime exception will be thrown(Java), not sure what happens in other languages.

What is the expected output? What do you see instead?
Even if no required fields are explicitly set when creating the protocol buffer, since the fields have default values you should not have to set the values of the fields. Instead, an exception is thrown because the fields, while they have a default value, have not explicitly been set in user-level code.

What version of the product are you using? On what operating system?
2.3.0, Linux(Ubuntu)

Please provide any additional information below.
Example:
message Information{
required string text = 1 [default = "hello"];
}

//pseudo-code below
main(){
Information protocol = Information.newBuilder().setText("google").build(); //works Information protocol = Information.newBuilder().build(); //required fields are not set, an exception is raised.
}


--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to