Skip to content

Emit multipart parts with empty bodies in PartGenerator - #37202

Open
shaggyinsomniac wants to merge 1 commit into
spring-projects:mainfrom
shaggyinsomniac:multipart-empty-parts
Open

Emit multipart parts with empty bodies in PartGenerator#37202
shaggyinsomniac wants to merge 1 commit into
spring-projects:mainfrom
shaggyinsomniac:multipart-empty-parts

Conversation

@shaggyinsomniac

Copy link
Copy Markdown

Fixes #37200

Description

Parts were emitted only from PartListener.onBody(buffer, last=true), so a part with an empty body (for example a blank form field, or a trailing empty part) was silently dropped from the resulting MultiValueMap, and was indistinguishable from an absent field.

This carries over the fix from the reactive DefaultPartHttpMessageReader (#30953): State gains an onComplete() callback that emits the part — also when it has an empty body. It is invoked when a new part begins (previous part completes without a final body chunk) and when parsing completes (final part).

Emission is guarded per state so a part completed via onBody(last=true) is not emitted twice.

Test coverage

  • readMultipartEmptyPart() — empty form field followed by a non-empty one
  • readMultipartEmptyLastPart() — non-empty field followed by a trailing empty part
  • Both fail on main (part missing from the result) and pass with this change; the full :spring-web:test suite (3,919 tests) passes

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 27, 2026
@bclozel bclozel added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Aug 27, 2026
@bclozel

bclozel commented Aug 27, 2026

Copy link
Copy Markdown
Member

Please sign the DCO

@bclozel bclozel added the status: waiting-for-feedback We need additional information before we can continue label Aug 27, 2026
Parts were emitted only from PartListener.onBody(buffer, last=true), so a
part with an empty body (for example a blank form field, or a trailing
empty part) was silently dropped from the resulting MultiValueMap, and
was indistinguishable from an absent field.

This carries over the fix from the reactive DefaultPartHttpMessageReader
(spring-framework#30953): State gains an onComplete() callback that emits
the part, also when it has an empty body. It is invoked when a new part
begins, and when parsing completes for the final part.

Signed-off-by: Sagar Chanchal <Sagarr2112@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: web Issues in web modules (web, webmvc, webflux, websocket) status: waiting-for-feedback We need additional information before we can continue 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.

Multipart HttpMessageConverter drops parts with empty bodies

3 participants