Skip to content
Advertisement

Spring WebClient corrupts binary data

I’m sending files containing binary data from service A to service B. When the number of files is relatively small (let’s say 5) everything works well. However, when I try to send more files (let’s say several hundred) it sometimes fails. I tried to check what is happening with this binary data, and it looks like WebClient corrupts it in some way (weird padding appears at the end).

I created a minimal reproducible example to illustrate this issue.

Endpoint in service B (consuming binary files):

JavaScript

Tests illustrating how the service A sends data:

JavaScript

What could be the reason for this data corruption?

Advertisement

Answer

It turned out to be a bug in the Spring Framework (in the MultipartParser class to be more precise). I have created a GitHub issue which will be fixed in the next version (5.3.16). The bug is fixed by this commit.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement