Skip to content

MultipartBody endless loop reading ByteArrayPart with empty byte array  #1089

Closed
@matterche

Description

@matterche

Hi,

We're working with play framework 2.4.x and encounter problems when posting multipart form data to some webserver. Sometimes it happens that users upload empty files with size 0. In this case reading the Multipart body is stuck in an endless loop.

I was able to reproduce this behavior with async-http-client-1.9.32:

final List<Part> parts = new ArrayList<>();
byte[] emptyByteAray = {};
parts.add(new ByteArrayPart("baPart", emptyByteAray, "application/test", UTF_8, "fileName"));
final Body multipartBody = MultipartUtils.newMultipartBody(parts, new FluentCaseInsensitiveStringsMap());
final ByteBuffer buffer = ByteBuffer.allocate(8192);
    try {
        multipartBody.read(buffer);
    } catch (IOException e) {
        e.printStackTrace();
    }

I've also tested with async-http-client-project-2.0.0-RC7 and could not reproduce the issue anymore.

Would you mind providing a fix for 1.9.x?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions