NamedDataSource should implement EncodingAware
ben-manes opened this issue · 3 comments
ben-manes commented
When attaching a file, the content-type is inferred by MimeBodyPart
by reading from the input stream. This occurs twice per attachment before the data is written out, resulting in 3 http calls. If the DataSource
implements javax.mail.EncodingAware
then this used if the result is non-null. When the file type is known, such as a pdf, this should avoid the extra hops. Unfortunately the given DataSource
is decorated by NamedDataSource
, so this optimization is not possible.
bbottema commented
What about this?
class NamedDataSource implements DataSource, EncodingAware {
(..)
@Override
public String getEncoding() {
return (this.dataSource instanceof EncodingAware) ? ((EncodingAware) this.dataSource).getEncoding() : null;
}
}
ben-manes commented
Yep, that is what I envisioned.
bbottema commented
Released in 5.0.2.