Re: Bug: duplicate message ids
Boris Folgmann <[email protected]> Thu, 26 Apr 2007 11:55:38 +0200
| Newsgroups | gmane.comp.java.classpath.extensions.javamail |
|---|---|
| Message-ID | <[email protected]> |
Hi Chris,
Chris Burdess schrieb/wrote:
> I can update the algorithm to use the FQDN of the host, that's not a
> problem (although it means that GNU JavaMail will rely on Java 1.4 or
> later, I don't think that will be a problem for most people).
Yes please, I think that would be a good idea.
> If the second number is not changing, that indicates a much more
> serious problem. Could you give an example of the code you're using
> to create and send the messages? You're not reusing MimeMessage
> object instances?
Both numbers (before and after the dot) are not changing, that's why there
are real duplicate ids. It's not my code, but I found the right method in
org.apache.log4j.net.SMTPAppender I think:
/**
Send the contents of the cyclic buffer as an e-mail message.
*/
protected
void sendBuffer() {
// Note: this code already owns the monitor for this
// appender. This frees us from needing to synchronize on 'cb'.
try {
MimeBodyPart part = new MimeBodyPart();
StringBuffer sbuf = new StringBuffer();
String t = layout.getHeader();
if(t != null)
sbuf.append(t);
int len = cb.length();
for(int i = 0; i < len; i++) {
//sbuf.append(MimeUtility.encodeText(layout.format(cb.get())));
LoggingEvent event = cb.get();
sbuf.append(layout.format(event));
if(layout.ignoresThrowable()) {
String[] s = event.getThrowableStrRep();
if (s != null) {
for(int j = 0; j < s.length; j++) {
sbuf.append(s[j]);
}
}
}
}
t = layout.getFooter();
if(t != null)
sbuf.append(t);
part.setContent(sbuf.toString(), layout.getContentType());
Multipart mp = new MimeMultipart();
mp.addBodyPart(part);
msg.setContent(mp);
msg.setSentDate(new Date());
Transport.send(msg);
} catch(Exception e) {
LogLog.error("Error occured while sending e-mail notification.", e);
}
}