JAMES-4172 Fix truncated downloads for non-SingleBody EmailBodyPart b…#2940
Open
omerfarukicen wants to merge 1 commit intoapache:masterfrom
Open
JAMES-4172 Fix truncated downloads for non-SingleBody EmailBodyPart b…#2940omerfarukicen wants to merge 1 commit intoapache:masterfrom
omerfarukicen wants to merge 1 commit intoapache:masterfrom
Conversation
…lobs In EmailBodyPartBlob, the size and content methods used different calculation paths for non-SingleBody parts (e.g. message/rfc822): - size relied on SizeUtils.sizeOf(entity) which returns the decoded size via SingleBody.size() - content used DefaultMessageWriter.writeBody() which re-encodes the content (e.g. base64), producing more bytes than the decoded size This mismatch caused Content-Length to be set smaller than the actual response body, resulting in truncated .eml downloads with missing attachments and MIME boundaries. Fix by caching the written body bytes in a lazy val so that both size and content use the same data, ensuring Content-Length matches the actual stream length.
chibenwa
reviewed
Feb 13, 2026
Contributor
Author
|
The test This is expected: the old code used Since Shall I update the test to expect |
Contributor
Likely yes! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://issues.apache.org/jira/browse/JAMES-4172
In EmailBodyPartBlob, the size and content methods used different calculation paths for non-SingleBody parts (e.g. message/rfc822):
This mismatch caused Content-Length to be set smaller than the actual response body, resulting in truncated .eml downloads with missing attachments and MIME boundaries.
Fix by caching the written body bytes in a lazy val so that both size and content use the same data, ensuring Content-Length matches the actual stream length.