Skip to content

stub: fix onError metadata race condition #11979

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

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix metadata
  • Loading branch information
JoeCqupt committed Mar 25, 2025
commit e47028a732d6b04c6a03565a99089c128b93bbc5
7 changes: 4 additions & 3 deletions stub/src/main/java/io/grpc/stub/ServerCalls.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,10 @@ public void onNext(RespT response) {

@Override
public void onError(Throwable t) {
Metadata metadata = Status.trailersFromThrowable(t);
if (metadata == null) {
metadata = new Metadata();
Metadata metadata = new Metadata();
Metadata trailers = Status.trailersFromThrowable(t);
if (trailers != null) {
metadata.merge(trailers);
}
call.close(Status.fromThrowable(t), metadata);
aborted = true;
Expand Down