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

fix: Avoid NPE in GrpcMetadataImpl #1854 #1855

Merged
merged 2 commits into from
Oct 17, 2023
Merged

fix: Avoid NPE in GrpcMetadataImpl #1854 #1855

merged 2 commits into from
Oct 17, 2023

Conversation

johanandren
Copy link
Member

Exception may not have any trailers. Also, fail fast if created with null delegate in some place we don't expected.

References #1854

new GrpcServiceException(
ex.getStatus,
new RichGrpcMetadataImpl(
ex.getStatus,
Copy link
Contributor

Choose a reason for hiding this comment

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

Unrelated to this PR, but why we use RichGrpcMetadataImpl, but above we just use GrpcMetadataImpl?

Copy link
Member Author

Choose a reason for hiding this comment

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

We want to propagate the structured error details if present, but maybe cleaner and more correct to select between GrpcMetadataImpl and RichGrpcMedataImpl on the presence of trailers instead of giving an empty metadata like I did. I'll do that instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, looking at it some more, actually, I'm not so sure why we are not passing RichGrpcMetadataImpl above, that looks like the right thing to do.

Copy link
Member Author

Choose a reason for hiding this comment

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

312a11a should do the trick

Also, in the case of going from proto details we always have trailers
new GrpcMetadataImpl(
// might not be present
Option(statusRuntimeException.getTrailers).getOrElse(new io.grpc.Metadata())))
new RichGrpcMetadataImpl(statusRuntimeException.getStatus, statusRuntimeException.getTrailers))
Copy link
Member Author

Choose a reason for hiding this comment

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

we just converted, trailers always present here

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

@johanandren johanandren merged commit ccc7ce2 into main Oct 17, 2023
12 checks passed
@johanandren johanandren deleted the wip-fix-1854-npe branch October 17, 2023 11:27
johanandren added a commit that referenced this pull request Dec 14, 2023
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