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

MessageEncodingException should take an encoding name only #1940

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Nov 4, 2021

Motivation:

MessageEncodingException expects an encoding name only, not a cause.
It already has a prepared cause inside a ctor.

Modifications:

  • Pass encoding to the MessageEncodingException ctor instead of a
    cause;

Result:

Users see a correct cause message for MessageEncodingException.

Motivation:

`MessageEncodingException` expects an encoding name only, not a cause.
It already has a prepared cause inside a ctor.

Modificaitons:

- Pass encoding to the `MessageEncodingException` ctor instead of a
cause;

Result:

Users see a correct cause message for `MessageEncodingException`.
@idelpivnitskiy idelpivnitskiy force-pushed the ProtoBufSerializationProviderBuilder branch from eadd7c1 to a621e2a Compare November 4, 2021 22:41
@idelpivnitskiy idelpivnitskiy changed the base branch from 0.41 to main November 4, 2021 22:41
@idelpivnitskiy idelpivnitskiy self-assigned this Nov 4, 2021
@@ -172,7 +172,7 @@ public GrpcSerializationProvider build() {
@SuppressWarnings("unchecked")
HttpSerializer<T> httpSerializer = serializersForType.get(codec);
if (httpSerializer == null) {
throw new MessageEncodingException("Unknown encoding: " + codec.name());
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps instead of the encoding name, which may be non-canonical, the exception could be created with the ContentCodec instance responsible.

Copy link
Member Author

Choose a reason for hiding this comment

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

This PR mostly targets 0.41 branch. In the main branch, old serialization is already deprecated. This exception type was missed, but will be deprecated by #1924. Will minimize changes for the code that is going away soon.

@idelpivnitskiy idelpivnitskiy merged commit b4e3334 into apple:main Nov 8, 2021
@idelpivnitskiy idelpivnitskiy deleted the ProtoBufSerializationProviderBuilder branch November 8, 2021 23:58
idelpivnitskiy added a commit that referenced this pull request Nov 9, 2021
Motivation:

`MessageEncodingException` expects an encoding name only, not a cause.
It already has a prepared cause inside a ctor.

Modificaitons:

- Pass encoding to the `MessageEncodingException` ctor instead of a
cause;

Result:

Users see a correct cause message for `MessageEncodingException`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants