[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Classpathx-discuss] Bug in JAF 1.1 (ObjectDataContentHandler)
From: |
Markus Wiederkehr |
Subject: |
[Classpathx-discuss] Bug in JAF 1.1 (ObjectDataContentHandler) |
Date: |
Wed, 10 May 2006 16:43:40 +0200 |
I tried to send an e-mail using GNU JavaMail 1.1.1 in combination with
GNU Activation 1.1 with this simple code:
Session session = Session.getInstance(new Properties());
MimeMessage mm = new MimeMessage(session);
mm.setSender(new InternetAddress(sender));
mm.setRecipient(RecipientType.TO, new InternetAddress(recipient));
mm.setSubject(subject);
mm.setText(message);
Transport transport = session.getTransport("smtp");
transport.connect(host_, port_, "", "");
Address[] recipients = { new InternetAddress(recipient) };
transport.sendMessage(mm, recipients);
This led to the following exception:
javax.mail.SendFailedException: no object DCH for MIME type text/plain;
charset=UTF-8
at gnu.mail.providers.smtp.SMTPTransport.sendMessage(SMTPTransport.java:520)
Tracking down the problem I found this code in
javax.activation.ObjectDataContentHandler:
public void writeTo(Object object, String mimeType, OutputStream out)
throws IOException
{
if (dch != null)
{
dch.writeTo(object, mimeType, out);
}
throw new UnsupportedDataTypeException("no object DCH for MIME type " +
mimeType);
}
This method seems to have a bug because the exception gets thrown even
if dch is not null. Changing this method to following solved the
problem:
public void writeTo(Object object, String mimeType, OutputStream out)
throws IOException
{
if (dch == null)
throw new UnsupportedDataTypeException("no object DCH for MIME type " +
mimeType);
dch.writeTo(object, mimeType, out);
}
I hope this is useful to someone...
Markus
--
Always remember you're unique. Just like everyone else.
- [Classpathx-discuss] Bug in JAF 1.1 (ObjectDataContentHandler),
Markus Wiederkehr <=