Class SelectorInvalidReceiveTest
java.lang.Object
org.apache.kafka.common.network.SelectorInvalidReceiveTest
Tests for the Selector's handling of
InvalidReceiveException thrown when a peer sends an
oversized request. The behavior under test is transport-agnostic (it's driven by the size prefix
read in NetworkReceive.readFrom(ScatteringByteChannel)), so this test deliberately uses a plaintext
channel builder and is not part of SelectorTest's inheritance hierarchy.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidsetUp()voidtearDown()voidWhenfailedAuthenticationDelayMsis disabled, anInvalidReceiveExceptioncloses the channel immediately — preserving the pre-existing behavior for deployments that have not opted into the delay.voidWhen a peer sends an oversized request that triggersInvalidReceiveExceptioninNetworkReceive.readFrom(ScatteringByteChannel), the channel is parked indelayedClosingChannelsforfailedAuthenticationDelayMsbefore being closed — mirroring the authentication-failure path.
-
Constructor Details
-
SelectorInvalidReceiveTest
public SelectorInvalidReceiveTest()
-
-
Method Details
-
setUp
@BeforeEach public void setUp() -
tearDown
@AfterEach public void tearDown() -
testInvalidReceiveDelaysCloseWhenDelayConfigured
When a peer sends an oversized request that triggersInvalidReceiveExceptioninNetworkReceive.readFrom(ScatteringByteChannel), the channel is parked indelayedClosingChannelsforfailedAuthenticationDelayMsbefore being closed — mirroring the authentication-failure path. This slows down attackers that issue oversized requests in tight loops without changing the eventual outcome (the connection is still closed).- Throws:
Exception
-
testInvalidReceiveClosesImmediatelyWhenDelayDisabled
WhenfailedAuthenticationDelayMsis disabled, anInvalidReceiveExceptioncloses the channel immediately — preserving the pre-existing behavior for deployments that have not opted into the delay.- Throws:
Exception
-