Status: New
Owner: liuj...@google.com
Labels: Type-Defect Priority-Medium
New issue 506 by dav.co...@gmail.com: Java DynamicMessage.Builder#getField
doesn't return empty list for unset repeated Message fields, but a default
Message instead.
http://code.google.com/p/protobuf/issues/detail?id=506
What steps will reproduce the problem?
1. for any unset repeated Message field
2. call DynamicMessage.Builder#getField
3. returns the default Message (wrong!)
What is the expected output? What do you see instead?
Should return an empty list!
What version of the product are you using? On what operating system?
Java, protobuf 2.5
Please provide any additional information below.
The fix is easy:
instead of:
...
if (result == null) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
result = getDefaultInstance(field.getMessageType());
...
write:
...
if (result == null) {
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
if (field.isRepeated()) {
result = Collections.emptyList();
} else {
result = getDefaultInstance(field.getMessageType());
}
...
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups "Protocol
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.