@Override
    public int onDataRead(ChannelHandlerContext ctx, int streamId, ByteBuf data, int padding, boolean endOfStream)
            throws Http2Exception {
        if (endOfStream || data.isReadable()) {
            emptyDataFrames = 0;
        } else if (emptyDataFrames++ == maxConsecutiveEmptyFrames && !violationDetected) {
            violationDetected = true;
            throw Http2Exception.connectionError(Http2Error.ENHANCE_YOUR_CALM,
                    "Maximum number %d of empty data frames without end_of_stream flag received",
                    maxConsecutiveEmptyFrames);
        }

        return super.onDataRead(ctx, streamId, data, padding, endOfStream);
    }
@Test
    public void testEmptyDataFramesWithNonEmptyInBetween() throws Http2Exception {
        final Http2EmptyDataFrameListener listener = new Http2EmptyDataFrameListener(frameListener, 2);
        listener.onDataRead(ctx, 1, Unpooled.EMPTY_BUFFER, 0, false);
        listener.onDataRead(ctx, 1, nonEmpty, 0, false);

        listener.onDataRead(ctx, 1, Unpooled.EMPTY_BUFFER, 0, false);
        listener.onDataRead(ctx, 1, Unpooled.EMPTY_BUFFER, 0, false);

        assertThrows(Http2Exception.class, new Executable() {
            @Override
            public void execute() throws Throwable {
                listener.onDataRead(ctx, 1, Unpooled.EMPTY_BUFFER, 0, false);
            }
        });
        verify(frameListener, times(4)).onDataRead(eq(ctx), eq(1), any(ByteBuf.class), eq(0), eq(false));
    }