Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DynamicMessage.setField doesn't allow setting value on a repeated enum field! #17

Closed
protobufel opened this issue Sep 9, 2014 · 3 comments · Fixed by #38
Closed

DynamicMessage.setField doesn't allow setting value on a repeated enum field! #17

protobufel opened this issue Sep 9, 2014 · 3 comments · Fixed by #38
Labels
Milestone

Comments

@protobufel
Copy link

The DynamicMessage.setField has wrong check, preventing setting any ENUM type list on it!
This is a major bug; this has been introduced only in 2.6.0.

Here is the excerpt from the source:

public Builder setField(FieldDescriptor field, Object value) {
  verifyContainingType(field);
  ensureIsMutable();
  if (field.getType() == FieldDescriptor.Type.ENUM) {
    verifyEnumType(field, value);
  }

...
And verifyEnumType doesn't check for repeated value; here it is:

private void verifyEnumType(FieldDescriptor field, Object value) {
  if (value == null) {
    throw new NullPointerException();
  }
  if (!(value instanceof EnumValueDescriptor)) {
    throw new IllegalArgumentException(
      "DynamicMessage should use EnumValueDescriptor to set Enum Value.");
  }

...
If field is repeated, then its value is instanceof List, will never be EnumValueDescriptor!

@xfxyjwf xfxyjwf added the bug label Sep 9, 2014
@protobufel
Copy link
Author

  1. Is there any ETA for the fix? This bug renders entire DynamicMessage unusable - any merge, build, clone, parse, etc. methods won't work in the presence of any repeated enum field!

The bug is a MAJOR one, a showstopper!

Thanks in advance,
David

@xfxyjwf
Copy link
Contributor

xfxyjwf commented Sep 10, 2014

Sorry, we don't have an ETA for this. It should be fixed in the next minor release which hasn't been scheduled yet.

I believe most uses of DynamicMessage still work as we have unit-tests covering DynamicMessage:
https://github.com/google/protobuf/blob/master/java/src/test/java/com/google/protobuf/DynamicMessageTest.java

Presumably these tests are not failing despite of the bug. In most places we use addRepeatedField()/setRepeatedField() instead of setField() to manipulate repeated fields. Users could use these methods as a workaround as well.

@xfxyjwf xfxyjwf added this to the Release 2.6.1 milestone Sep 10, 2014
@protobufel
Copy link
Author

Nope, the merge uses setField, and the clone, new builder, and build, and
the rest use the merge!

This is really the showstopper! Update the tests and you'll see it!

Also, most of the users will care only about the Maven Central, so this
minor emergency release could be done just for Java there.
On Sep 10, 2014 1:12 PM, "xfxyjwf" [email protected] wrote:

Sorry, we don't have an ETA for this. It should be fixed in the next minor
release which hasn't been scheduled yet.

I believe most uses of DynamicMessage still work as we have unit-tests
covering DynamicMessage:

https://github.com/google/protobuf/blob/master/java/src/test/java/com/google/protobuf/DynamicMessageTest.java

Presumably these tests are not failing despite of the bug. In most places
we use addRepeatedField()/setRepeatedField() instead of setField() to
manipulate repeated fields. Users could use these methods as a workaround
as well.


Reply to this email directly or view it on GitHub
#17 (comment).

TeBoring pushed a commit to TeBoring/protobuf that referenced this issue Jan 19, 2019
GerHobbelt pushed a commit to GerHobbelt/protobuf that referenced this issue Aug 4, 2024
…olbuffers#17)

The premake build structure has been simplified and rewritten to reduce
the boilerplate needed to add additional configurations while forcing
the unique settings of a project to be defined. Migrate some defines
and compiler options to the global settings and remove all the old
boilerplate from this project.

Issue-number: https://devtopia.esri.com/runtime/devops/issues/830
Signed-off-by: Christian O. Venegas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants