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
Expose unexpected decoding exception reason #5620
base: main
Are you sure you want to change the base?
Conversation
…tion when encounter edge case exception
core/src/test/java/com/linecorp/armeria/client/encoding/TestEmbeddedChannel.java
Outdated
Show resolved
Hide resolved
import io.netty.channel.embedded.EmbeddedChannel; | ||
import io.netty.handler.codec.compression.DecompressionException; | ||
|
||
class TestStreamDecoder implements StreamDecoder { |
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.
What do you think of extending AbstractStreamDecoder
instead of copying the code?
If necessary, we may move this class to common.encoding
.
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.
That would be great. I've changed this class' directory path. Extending AbstractStreamDecoder for the test class is what i wanted, not recreating the same code. Thanks for allowed to do this.
throw new UnexpectedDecodeException( | ||
"Unexpected exception has occurred. " + | ||
"This exception is not caused by the buffer reaching max size. Exception message: " + | ||
message); |
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.
I think it is okay to re-throw the exception as is if we don't have additional information for the error message.
That said, your test code is invaluable to verify the code.
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.
Your words mean a lot to me. Thank you.
And please sign the ICLA 🙇 |
…change the name of test classes
I've signed ICLA. Sorry for missed this. |
core/src/main/java/com/linecorp/armeria/common/UnexpectedDecodeException.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/UnexpectedDecodeException.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/encoding/AbstractStreamDecoder.java
Outdated
Show resolved
Hide resolved
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.
Changes look good to me once https://github.com/line/armeria/pull/5620/files#r1574617073 is handled 👍 👍 👍
core/src/test/java/com/linecorp/armeria/common/encoding/DefaultHttpDecodedResponseTest.java
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/common/encoding/TestStreamDecoder.java
Outdated
Show resolved
Hide resolved
core/src/test/java/com/linecorp/armeria/common/encoding/TestStreamDecoder.java
Outdated
Show resolved
Hide resolved
I've applied trustin's review. |
core/src/test/java/com/linecorp/armeria/common/encoding/TestStreamDecoder.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/common/encoding/UnexpectedDecodeException.java
Outdated
Show resolved
Hide resolved
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.
LGTM once @trustin's comments are addressed. 👍
Motivation:
Issue: #5177
Modifications:
UnexpectedDecodeException
to throw an exception if aDecompressionException
is thrown and the if condition is not met.DecompressionException
and that understanding the internal implementation of the decoder is not what i am testing, so i decided to use a mock at the first time. However, it was difficult to use 'mock' because the 'decoder' variable is created and initialized in the constructor instead of being injected, and it was difficult to manipulate it using inheritance because the access modifier level of the constructor ofAbstractStreamDecoder
is 'protected'. Therefore, I added two separate classes for testing. I don't think this �structure is efficient, and I think it's hard to manage whenAbstractStreamDecoder
class changes are made. I couldn't think of any other way to do it, so I went with this, but if anyone has a better idea, I'd love to hear it.Result:
AbstractStreamDecoder
#5177