Http2EmptyDataFrameConnectionDecoder.frameListener() should return unwrapped Http2FrameListener (#9467)
Motivation: As we decorate the Http2FrameListener under the covers we should ensure the user can still access the original Http2FrameListener. Modifications: - Unwrap the Http2FrameListener in frameListener() - Add unit test Result: Less suprises for users.
This commit is contained in:
parent
04d71b3773
commit
d4038d0937
@ -24,7 +24,7 @@ final class Http2EmptyDataFrameConnectionDecoder extends DecoratingHttp2Connecti
|
|||||||
|
|
||||||
private final int maxConsecutiveEmptyFrames;
|
private final int maxConsecutiveEmptyFrames;
|
||||||
|
|
||||||
Http2EmptyDataFrameConnectionDecoder(Http2ConnectionDecoder delegate, int maxConsecutiveEmptyFrames) {
|
Http2EmptyDataFrameConnectionDecoder(Http2ConnectionDecoder delegate, int maxConsecutiveEmptyFrames) {
|
||||||
super(delegate);
|
super(delegate);
|
||||||
this.maxConsecutiveEmptyFrames = ObjectUtil.checkPositive(
|
this.maxConsecutiveEmptyFrames = ObjectUtil.checkPositive(
|
||||||
maxConsecutiveEmptyFrames, "maxConsecutiveEmptyFrames");
|
maxConsecutiveEmptyFrames, "maxConsecutiveEmptyFrames");
|
||||||
@ -38,4 +38,19 @@ final class Http2EmptyDataFrameConnectionDecoder extends DecoratingHttp2Connecti
|
|||||||
super.frameListener(null);
|
super.frameListener(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Http2FrameListener frameListener() {
|
||||||
|
Http2FrameListener frameListener = frameListener0();
|
||||||
|
// Unwrap the original Http2FrameListener as we add this decoder under the hood.
|
||||||
|
if (frameListener instanceof Http2EmptyDataFrameListener) {
|
||||||
|
return ((Http2EmptyDataFrameListener) frameListener).listener;
|
||||||
|
}
|
||||||
|
return frameListener;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Package-private for testing
|
||||||
|
Http2FrameListener frameListener0() {
|
||||||
|
return super.frameListener();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,9 @@ public class Http2EmptyDataFrameConnectionDecoderTest {
|
|||||||
decoder.frameListener(listener);
|
decoder.frameListener(listener);
|
||||||
verify(delegate).frameListener(listenerArgumentCaptor.capture());
|
verify(delegate).frameListener(listenerArgumentCaptor.capture());
|
||||||
|
|
||||||
assertThat(decoder.frameListener(), CoreMatchers.instanceOf(Http2EmptyDataFrameListener.class));
|
assertThat(decoder.frameListener(),
|
||||||
|
CoreMatchers.not(CoreMatchers.instanceOf(Http2EmptyDataFrameListener.class)));
|
||||||
|
assertThat(decoder.frameListener0(), CoreMatchers.instanceOf(Http2EmptyDataFrameListener.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user