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
a1742d95da
commit
e4d9a17ad9
@ -38,4 +38,19 @@ final class Http2EmptyDataFrameConnectionDecoder extends DecoratingHttp2Connecti
|
||||
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);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user