Class ByteBufReceiveBoundedRequestTest
java.lang.Object
org.apache.kafka.common.network.netty.ByteBufReceiveBoundedRequestTest
Tests for the bounded-request size cap in
ByteBufReceive: oversized requests on configured
api keys are rejected after the 4-byte api header is read, before the (potentially large) payload
is retained into the composite buffer. This mirrors NetworkReceive on the classic
SocketServer path.
The wire buffers are synthetic: a 4-byte size prefix can declare an oversized payload without the test ever allocating it — which is exactly the property the guard relies on to reject early.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThe api header may arrive split across multiple buffers (HTTP/2 DATA frames).voidbytesRead() accounts for api-header bytes that have been read but not yet folded into the composite buffer, so the count is accurate throughout the api-header phase.voidWith the cap disabled (NetworkReceive.UNLIMITED), even an oversized bounded api key is accepted — the feature is a no-op.voidAn empty bounded-api-key set means no api is capped, so an oversized request is accepted even though a cap value is configured.voidAn oversized request on a bounded api key is rejected after the api header is read — before the payload is provided at all (only the size prefix + api header bytes are fed).voidAn oversized request on an api key NOT in the bounded set (e.g.voidA request on a bounded api key that is within the cap skips the api-header phase entirely (no rejection, no extra work) and completes normally.
-
Constructor Details
-
ByteBufReceiveBoundedRequestTest
public ByteBufReceiveBoundedRequestTest()
-
-
Method Details
-
testOversizedBoundedRequestRejected
@Test public void testOversizedBoundedRequestRejected()An oversized request on a bounded api key is rejected after the api header is read — before the payload is provided at all (only the size prefix + api header bytes are fed). -
testOversizedNonBoundedRequestAccepted
@Test public void testOversizedNonBoundedRequestAccepted()An oversized request on an api key NOT in the bounded set (e.g. Produce) is accepted: the 4 api-header bytes are folded back into the payload and the request completes normally. -
testWithinLimitBoundedRequestSkipsApiHeaderPhase
@Test public void testWithinLimitBoundedRequestSkipsApiHeaderPhase()A request on a bounded api key that is within the cap skips the api-header phase entirely (no rejection, no extra work) and completes normally. -
testDisabledCapAcceptsOversizedBoundedRequest
@Test public void testDisabledCapAcceptsOversizedBoundedRequest()With the cap disabled (NetworkReceive.UNLIMITED), even an oversized bounded api key is accepted — the feature is a no-op. -
testEmptyApiKeySetAcceptsOversizedRequest
@Test public void testEmptyApiKeySetAcceptsOversizedRequest()An empty bounded-api-key set means no api is capped, so an oversized request is accepted even though a cap value is configured. -
testApiHeaderSplitAcrossBuffersStillRejected
@Test public void testApiHeaderSplitAcrossBuffersStillRejected()The api header may arrive split across multiple buffers (HTTP/2 DATA frames). The reject still fires once the 4-byte header is fully assembled. -
testBytesReadDuringApiHeaderPhase
@Test public void testBytesReadDuringApiHeaderPhase()bytesRead() accounts for api-header bytes that have been read but not yet folded into the composite buffer, so the count is accurate throughout the api-header phase.
-