Skip to content

Use bulk access in multiple-delimiter matching - #37741

Open
cj848 wants to merge 1 commit into
spring-projects:mainfrom
cj848:data-buffers-forEach-byte
Open

cj848 wants to merge 1 commit into
spring-projects:mainfrom
cj848:data-buffers-forEach-byte

Conversation

@cj848

@cj848 cj848 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Prior to this commit, DataBuffers.CompositeMatcher.match indexed the buffer byte by byte
through DataBuffer.getByte. Some DataBuffer implementations record an access for every
call: Netty's leak-aware buffers capture a stack trace per access when paranoid leak
detection is enabled, so matching a multipart body became orders of magnitude slower.

With Spring Framework 7.1.0, a WebFlux application using PartEventHttpMessageReader on
Netty with -Dio.netty.leakDetection.level=paranoid sees multipart uploads time out
(408 responses, multi-second and multi-minute hangs) while the event loop spends its time
in AdvancedLeakAwareByteBuf.getByte.

This commit uses DataBuffer.forEachByte instead, which delegates to the underlying
implementation's bulk path, as the previous NestedMatcher implementation did. The new
test verifies that the matcher does not call DataBuffer.getByte.

Prior to this commit, CompositeMatcher.match indexed the buffer byte by
byte through DataBuffer.getByte. Some DataBuffer implementations record
an access for each call (for example, Netty's leak-aware buffers capture
a stack trace when paranoid leak detection is enabled), so matching a
multipart body made parsing orders of magnitude slower and multipart
requests timed out.

This commit uses DataBuffer.forEachByte instead, which delegates to the
underlying implementation's bulk path, as the previous NestedMatcher
implementation did.

Signed-off-by: Hyunsik Kang <cj848@hanmail.net>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants