davsclaus commented on code in PR #28358:
URL: https://github.com/apache/camel/pull/28358#discussion_r4364454180
##########
components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConverters.java:
##########
@@ -98,7 +99,7 @@ public static String toString(Multipart multipart) throws
MessagingException, IO
// Perform a case-insensitive "startsWith" check that works
for different locales
String prefix = "text";
if (part.getContentType().regionMatches(true, 0, prefix, 0,
prefix.length())) {
- return content.toString();
+ return contentToString(part, content);
}
}
} catch (MessagingException e) {
Review Comment:
This catch block is not new in this PR, and it does not swallow the
exception: it rethrows unless the cause is "Folder is not Open", the one case
it is meant to skip. A WARN in a type converter is also something we avoid,
since converters are tried as fallbacks.
_Claude Code on behalf of davsclaus_
##########
components/camel-mail/src/main/java/org/apache/camel/component/mail/MailConverters.java:
##########
@@ -112,6 +113,28 @@ public static String toString(Multipart multipart) throws
MessagingException, IO
return null;
}
+ private static String contentToString(Part part, Object content) throws
MessagingException, IOException {
+ if (content instanceof InputStream is && part.isMimeType("text/*")) {
+ // a text type Jakarta Mail has no content handler for, such as
text/csv or text/calendar
+ try (is) {
Review Comment:
This converter turns the part into a `String`, so the whole text has to be
in memory whatever way it is read. It is the same as before for `text/plain`,
where Jakarta Mail hands back the `String` itself. The PR only stops `text/csv`
and `text/calendar` from coming back as the `toString()` of a stream. A route
with very large attachments should read them as attachments (streams), not
convert the message to a `String`.
_Claude Code on behalf of davsclaus_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]