-
Notifications
You must be signed in to change notification settings - Fork 901
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
Refactor GrpcStatus to implement GrpcExceptionHandlerFunction #5571
Changes from 3 commits
c33f8ea
30dd216
866a041
3a5585f
1e0a4d2
0c804ef
a88f3c3
cccbe7d
5c56c80
0d6f75c
d38f3be
8604cf5
0bd68e0
63737b1
fb0692a
f68bd28
894fbba
7090d2c
a35dc16
a9a28ba
0704f71
e7b9908
7244059
10245db
c717229
81f3d3a
d1ff8b9
9603904
5b6dba4
99d5fbb
81c954d
0cef19b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,10 +64,10 @@ | |
import com.linecorp.armeria.common.util.TimeoutMode; | ||
import com.linecorp.armeria.internal.client.DefaultClientRequestContext; | ||
import com.linecorp.armeria.internal.client.grpc.protocol.InternalGrpcWebUtil; | ||
import com.linecorp.armeria.internal.common.grpc.DefaultGrpcExceptionHandlerFunction; | ||
import com.linecorp.armeria.internal.common.grpc.ForwardingCompressor; | ||
import com.linecorp.armeria.internal.common.grpc.GrpcLogUtil; | ||
import com.linecorp.armeria.internal.common.grpc.GrpcMessageMarshaller; | ||
import com.linecorp.armeria.internal.common.grpc.GrpcStatus; | ||
import com.linecorp.armeria.internal.common.grpc.HttpStreamDeframer; | ||
import com.linecorp.armeria.internal.common.grpc.MetadataUtil; | ||
import com.linecorp.armeria.internal.common.grpc.StatusAndMetadata; | ||
|
@@ -248,9 +248,10 @@ | |
|
||
final BiFunction<ClientRequestContext, Throwable, HttpResponse> errorResponseFactory = | ||
(unused, cause) -> HttpResponse.ofFailure( | ||
GrpcStatus.fromThrowable(exceptionHandler, ctx, cause, metadata) | ||
.withDescription(cause.getMessage()) | ||
.asRuntimeException()); | ||
DefaultGrpcExceptionHandlerFunction.fromThrowable(exceptionHandler, ctx, cause, | ||
metadata) | ||
.withDescription(cause.getMessage()) | ||
.asRuntimeException()); | ||
final HttpResponse res = initContextAndExecuteWithFallback( | ||
httpClient, ctx, endpointGroup, HttpResponse::of, errorResponseFactory); | ||
|
||
|
@@ -424,7 +425,7 @@ | |
new Metadata()); | ||
} else { | ||
GrpcWebTrailers.set(ctx, trailers); | ||
GrpcStatus.reportStatus(trailers, this); | ||
DefaultGrpcExceptionHandlerFunction.reportStatus(trailers, this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the recommendation. I also think we should separate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applied feedback. Thanks |
||
} | ||
} finally { | ||
buf.release(); | ||
|
@@ -454,7 +455,8 @@ | |
}); | ||
} catch (Throwable t) { | ||
final Metadata metadata = new Metadata(); | ||
close(GrpcStatus.fromThrowable(exceptionHandler, ctx, t, metadata), metadata); | ||
close(DefaultGrpcExceptionHandlerFunction.fromThrowable(exceptionHandler, ctx, t, metadata), | ||
Check warning on line 458 in grpc/src/main/java/com/linecorp/armeria/internal/client/grpc/ArmeriaClientCall.java
|
||
ikhoon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
metadata); | ||
} | ||
} | ||
|
||
|
@@ -511,7 +513,8 @@ | |
|
||
private void closeWhenListenerThrows(Throwable t) { | ||
final Metadata metadata = new Metadata(); | ||
closeWhenEos(GrpcStatus.fromThrowable(exceptionHandler, ctx, t, metadata), metadata); | ||
closeWhenEos(DefaultGrpcExceptionHandlerFunction.fromThrowable(exceptionHandler, ctx, t, metadata), | ||
metadata); | ||
} | ||
|
||
private void closeWhenEos(Status status, Metadata metadata) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we set
DefaultGrpcExceptionHandlerFunction
as a fallback exception handler forexceptionHandler
when it is set in theGrpcClientBuilder
like we do inServerBuilder
?armeria/core/src/main/java/com/linecorp/armeria/server/ServerBuilder.java
Lines 2166 to 2172 in ad3519f
The rest of code should not access to
DefaultGrpcExceptionHandlerFunction
and use the composed one.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll modify to use
DefaultGrpcExceptionHandlerFunction
as fallback exception handler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Global comments) If
DefaultGrpcExceptionHandlerFunction
is set as the fallback, should we removeDefaultGrpcExceptionHandlerFunction
here and others?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied feedback. Thanks