Status: New
Owner:
liu...@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