Logging bug

1 view
Skip to first unread message

mlohbihler

unread,
Jul 15, 2010, 11:29:57 AM7/15/10
to Java Email Server
There is a small logging bug in SMTPSenderStandard that is making
troubleshooting difficult. At line 232 the line:

deliverRemoteMessage( (String)entry.getKey(), (List)entry.getValue(),
message, address );

... references "address", which was (likely) set in the preceding "if"
statement, and so is incorrect. This is actually ok, because the value
is only (but incorrectly) used in logging. The problem is that at line
491 the incorrect "address" should actually be "addresses". As it is,
in the logs it says that the message was sent multiple times to the
same address.

Loulou

unread,
Jul 16, 2010, 1:48:14 AM7/16/10
to Java Email Server
Hello,

Could you give the version that you're working on?

Loulou

unread,
Jul 16, 2010, 2:01:50 AM7/16/10
to Java Email Server
Oh ok i made a test in command line and log is as you describe :

INFO | jvm 1 | 2010/07/16 07:54:52 | 16 juil. 2010 07:54:52
com.ericdaugherty.mail.server.services.smtp.SMTPSenderStandard
$StandardDeliver deliverRemoteMessage
INFO | jvm 1 | 2010/07/16 07:54:52 | INFO: Delivery complete for
message 832ac6f9 to: us...@gmail.com
INFO | jvm 1 | 2010/07/16 07:54:54 | 16 juil. 2010 07:54:54
com.ericdaugherty.mail.server.services.smtp.SMTPRemoteSender
processreply
INFO | jvm 1 | 2010/07/16 07:54:54 | INFO: Session has ended
INFO | jvm 1 | 2010/07/16 07:54:54 | 16 juil. 2010 07:54:54
com.ericdaugherty.mail.server.services.smtp.SMTPSenderStandard
$StandardDeliver deliverRemoteMessage
INFO | jvm 1 | 2010/07/16 07:54:54 | INFO: Delivery complete for
message 832ac6f9 to: us...@gmail.com
INFO | jvm 1 | 2010/07/16 07:54:56 | 16 juil. 2010 07:54:56
com.ericdaugherty.mail.server.services.smtp.SMTPRemoteSender
processreply
INFO | jvm 1 | 2010/07/16 07:54:56 | INFO: Session has ended
INFO | jvm 1 | 2010/07/16 07:54:56 | 16 juil. 2010 07:54:56
com.ericdaugherty.mail.server.services.smtp.SMTPSenderStandard
$StandardDeliver deliverRemoteMessage
INFO | jvm 1 | 2010/07/16 07:54:56 | INFO: Delivery complete for
message 832ac6f9 to: us...@gmail.com

And us...@gmail.com is the last user i entered for RCPT TO command.

But i don't think problem is on the lines you mentionned, but here :

while(iter.hasNext()) {
address = iter.next();
if (!
perDomainAddresses.containsKey(address.getDomain())) {
perDomainAddresses.put(address.getDomain(), new
ArrayList());
}
if (!
perDomainAddresses.get(address.getDomain()).contains(address)) {

perDomainAddresses.get(address.getDomain()).add(address);
}

This code block is juste before the "big" while where is the
"deliverRemoteMessage( (String)entry.getKey(), (List)entry.getValue(),
message, address );"

Here value for address at the end of the while is the last value found
in the iterator. And adress value is not changed between here and
deliverRemoteMessage.

Loulou

unread,
Jul 16, 2010, 2:46:41 AM7/16/10
to Java Email Server
Given parameter "address" is not really useful between functions,
could be deleted from code.

I think you should modify this block :

SMTPRemoteSender smtpRemoteSender = new SMTPRemoteSender();
try {
smtpRemoteSender.sendMessage( domain, addresses,
message );
if( log.isInfoEnabled() ) {
log.info( "Delivery complete for message " +
message.getSMTPUID() + " to: " + address );
}
}

And encapsulated log.info( "Delivery complete for message " +
message.getSMTPUID() + " to: " + address ); in a for loop, as
"addresses" is a list containing all of email addresses for domain.

Loulou

unread,
Jul 16, 2010, 7:32:43 AM7/16/10
to Java Email Server
For the bug, you can replace the log line by :

if( log.isInfoEnabled() )
{
for(int i=0;i<addresses.size();i++)
log.info( "Delivery complete for message " +
message.getSMTPUID() + " to: " + addresses.get(i) );
}

There's another very interesting bug, in relation with yours. With my
code, you can see all the recipient and not only the last in log file.

But there's a problem on this line just before :

smtpRemoteSender.sendMessage( domain, addresses, message );

It seems this line try to send to all email addresses the message. But
i made a test, and imagine that you have 5 users for a same domain, as
gmail.com, if the first user does not exist and if the server - as
gmail server - replies error directly instead of accept message and
send a bounce after, it blocks sending for all users of domain.

Andreas Kyrmegalos

unread,
Jul 16, 2010, 7:16:15 PM7/16/10
to Java Email Server
I have slightly amended the logging output. But the log entry
is there simply to point out that delivery to the domain has
concluded, not to every recipient in the specific domain.

Thanks for catching that bug Loulou. It was actually a multi-line
response issue when a 4xx or 5xx response code is received
when supplying the recipient list. Multiple recipients have had
proper handling all along.

Build the corrected code from sourceforge.

Andreas

Loulou

unread,
Jul 17, 2010, 4:20:49 AM7/17/10
to Java Email Server
Code on Sourceforge seems to be the same, or i don't watch the right
page .... :-D

Andreas Kyrmegalos

unread,
Jul 17, 2010, 12:41:12 PM7/17/10
to Java Email Server

On 17 Ιούλ, 11:20, Loulou <arthiolis2...@gmail.com> wrote:
> Code on Sourceforge seems to be the same, or i don't watch the right
> page .... :-D

Revision 240 is definitely not the same, you can check the
differences.
The correction is not to be bundled for downloading until the next
beta.

Andreas

Loulou

unread,
Jul 17, 2010, 4:34:04 PM7/17/10
to Java Email Server
Thanks Andreas, and sorry for my question, but i didn't know where
find the modified code :-(

I found it here : http://sourceforge.net/projects/javaemailserver/develop

I think i will wait for release before add some features.

Thanks and have a good night.
Reply all
Reply to author
Forward
0 new messages