-
Notifications
You must be signed in to change notification settings - Fork 3.9k
11246 :: Unexpected error when server expands a compressed message to learn it is too large #12360
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
Changes from 8 commits
fe36e6d
61fbe27
bb929aa
1024a7f
5410196
14adfdb
631edd3
92b75a8
894dc66
65fbebb
3b9ebbe
55741e4
26095ef
f16cd6b
a511a77
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 |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ | |
| import static io.grpc.internal.GrpcUtil.CONTENT_LENGTH_KEY; | ||
| import static io.grpc.internal.GrpcUtil.MESSAGE_ACCEPT_ENCODING_KEY; | ||
| import static io.grpc.internal.GrpcUtil.MESSAGE_ENCODING_KEY; | ||
| import static io.grpc.internal.MessageDeframer.TooLongDecompressedMessageException; | ||
|
|
||
| import com.google.common.annotations.VisibleForTesting; | ||
| import com.google.common.base.Throwables; | ||
|
|
@@ -73,6 +74,7 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> { | |
| private boolean closeCalled; | ||
| private Compressor compressor; | ||
| private boolean messageSent; | ||
| private Status exceptionStatus = null; | ||
|
|
||
| ServerCallImpl(ServerStream stream, MethodDescriptor<ReqT, RespT> method, | ||
| Metadata inboundHeaders, Context.CancellableContext context, | ||
|
|
@@ -270,6 +272,11 @@ public SecurityLevel getSecurityLevel() { | |
| * on. | ||
| */ | ||
| private void handleInternalError(Throwable internalError) { | ||
| if (exceptionStatus != null) { | ||
| stream.close(exceptionStatus, new Metadata()); | ||
| exceptionStatus = null; | ||
| return; | ||
| } | ||
| log.log(Level.WARNING, "Cancelling the stream because of internal error", internalError); | ||
| Status status = (internalError instanceof StatusRuntimeException) | ||
| ? ((StatusRuntimeException) internalError).getStatus() | ||
|
|
@@ -338,6 +345,9 @@ private void messagesAvailableInternal(final MessageProducer producer) { | |
| } | ||
| message.close(); | ||
|
||
| } | ||
| } catch (TooLongDecompressedMessageException e) { | ||
| this.call.exceptionStatus = e.getStatus(); | ||
| this.call.handleInternalError(e); | ||
|
||
| } catch (Throwable t) { | ||
| GrpcUtil.closeQuietly(producer); | ||
| Throwables.throwIfUnchecked(t); | ||
|
|
||
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.
The suggestion was to just call handleInternalError that does stream.cancel but you are doing stream.close which is different.
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.
handleInternalError()results inStatus{code=CANCELLED, description=RST_STREAM closed stream. HTTP/2 error code: CANCEL, cause=null}