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

Unable to set multiple Capabilities in a single message when using Java/Kotlin protobuf #121

Closed
nephyst opened this issue Aug 18, 2022 · 4 comments · Fixed by #125
Closed
Assignees
Labels
required-for-stable Required to be resolved before 1.0

Comments

@nephyst
Copy link

nephyst commented Aug 18, 2022

AgentCapabilities capabilities = 4;

ServerCapabilities capabilities = 7;

The intent of these fields is to pack multiple flags into a single field. According to the protobuf docs, Enum fields only allow a single value. When compiled to Java or Kotlin the generated objects do not allow for setting multiple capability flags to a single enum.

This can be fixed by changing the field to be an int32 with manual bit packing, or by repeating the enum fields.

@nephyst
Copy link
Author

nephyst commented Aug 18, 2022

This is the setCapabilities method in the java ServerToAgent object builder:

      public Builder setCapabilities(opamp.proto.Opamp.ServerCapabilities value) {
        if (value == null) {
          throw new NullPointerException();
        }
        
        capabilities_ = value.getNumber();
        onChanged();
        return this;
      }

@tigrannajaryan
Copy link
Member

I think we need to change the bit fields to uint64. The enum declarations can stay to show what the bit values are.

@tigrannajaryan tigrannajaryan self-assigned this Sep 20, 2022
@tigrannajaryan tigrannajaryan added the required-for-stable Required to be resolved before 1.0 label Sep 20, 2022
tigrannajaryan added a commit to tigrannajaryan/opamp-spec that referenced this issue Sep 20, 2022
Resolves open-telemetry#121

In some languages enum fields are strongly typed and it is impossible
to assigned OR-ed values to the enum field. This makes impossible to
compose the bit fields properly.

This changes all bit field declarations from enum to uint64. The enum
declarations stay, so that bit definitions are clear.
@tigrannajaryan
Copy link
Member

@nephyst thanks for reporting the problem. Does this fix the problem in Java/Kotlin: #125 ?

@nephyst
Copy link
Author

nephyst commented Sep 22, 2022

Yes, thank you!

tigrannajaryan added a commit that referenced this issue Sep 22, 2022
Resolves #121

In some languages enum fields are strongly typed and it is impossible
to assigned OR-ed values to the enum field. This makes impossible to
compose the bit fields properly.

This changes all bit field declarations from enum to uint64. The enum
declarations stay, so that bit definitions are clear.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
required-for-stable Required to be resolved before 1.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants