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

servicetalk-grpc-protoc name conflict fixes #2157

Merged
merged 2 commits into from
Mar 22, 2022

Conversation

Scottmitch
Copy link
Member

Motivation:
servicetalk-grpc-protoc attempts to detect naming conflicts
and appends numbers to the end of the class names to avoid
the conflict. However in the event java_outer_classname isn't
specified and the service type name conflicts with the file name
a conflict is incorrectly detected which leads to forcing a 0
at the end of the service name.

Detection of implicit class name isn't consistent with
protobuf-java which may result in not generating code in the
same file when java_multiple_files = false.

Types (messages, enums) that start with a lower case value
would fail to compile due to CLassName.bestGuess restrictions.

Potential User Changes:
If you are in this scenario you must regenerate code and your
class names will change, requiring code changes.

Motivation:
servicetalk-grpc-protoc attempts to detect naming conflicts
and appends numbers to the end of the class names to avoid
the conflict. However in the event `java_outer_classname` isn't
specified and the service type name conflicts with the file name
a conflict is incorrectly detected which leads to forcing a `0`
at the end of the service name.

Detection of implicit class name isn't consistent with
protobuf-java which may result in not generating code in the
same file when `java_multiple_files = false`.

Types (messages, enums) that start with a lower case value
would fail to compile due to CLassName.bestGuess restrictions.

Potential User Changes:
If you are in this scenario you must regenerate code and your
class names will change, requiring code changes.
@Scottmitch Scottmitch force-pushed the grpc_protoc_conflict branch from 2f8e1b0 to b630be6 Compare March 19, 2022 03:44
}

// todo(scott): make first char lowercase
// https://github.com/protocolbuffers/protobuf/issues/9653
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once protocolbuffers/protobuf#9653 is fixed, these tests can be updated to validate behavior.

@bondolo bondolo added the bug Something isn't working label Mar 21, 2022
Copy link
Member

@idelpivnitskiy idelpivnitskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes LGTM.

If you are in this scenario you must regenerate code and your class names will change, requiring code changes.

IIUC the risk is minimal: (1) not many users are in this situation; (2) if they are, they likely already use java_outer_classname; (3) if they don't, they can use java_outer_classname before upgrading to the next version to avoid any code changes as part of the version bump. Right?

Trying to see if it's ok to merge into 0.42.x or defer until 0.43

@Scottmitch
Copy link
Member Author

Scottmitch commented Mar 22, 2022

@idelpivnitskiy - yes I agree with your assessment that the risk is minimal. Relying on default behavior is not well defined when the name isn't specified and you can even see that protobuf compiler has some uncovered bugs in this department.

@Scottmitch Scottmitch merged commit 40c3e3c into apple:main Mar 22, 2022
@Scottmitch Scottmitch deleted the grpc_protoc_conflict branch March 22, 2022 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants