Skip to content

Refine and better specify error handling in MultipartParser #36947

@rstoyanchev

Description

@rstoyanchev

This is for the new MultipartHttpMessageConverter for 7.1 added recently in #33263.

There are 3 levels of handling where exceptions can occur:
Multiparser (parse) -> Multiparser.State (data|complete) -> PartListener (onHeader|onBody)

At the lowest level, the only PartListener implementation (PartGenerator) handles any exception arising from the handling of body data, cleans up resources, and throws HttpMessageConversionException.

The middle layer Multiparser.State implementations can throw HttpMessageConversionException (e.g. header size exceeded), in which case they also delegate to PartListener#onError to clean up, but don't consistently clean up their own state. There is also an implicit reliance on PartListener to handle all exceptions, which is not made explicit.

At the top, Multiparser handles only InputStream read IOException by calling State#dispose and PartListener#onError to clean up resources. If the lower layers raise HttpMessageConversionException, it means that's been handled, but any other unexpected exception is not.

We can make the expectations and responsibilities clear across the layers, and also tighten handling.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions