Dion Gillard wrote:
On 6/29/05, Ramiro Pereira de Magalhaes <[EMAIL PROTECTED]> wrote:
Yes, I meant these timeout checks. Since commons-email uses dumbster 1.6
this change should work fine.
If a bad port number is given then the ServerSocket class used in
dumbster's main loop will throw a IOException informing what went wrong.
Yes, but the finally block in run() will call notifyAll() and return
the server object from the SimpleSmtpServer.start(port) method, right?
ServerSocket is used in SimpleSmtpServer.run() method. You can read it here:
http://cvs.sourceforge.net/viewcvs.py/dumbster/dumbster/src/com/dumbster/smtp/SimpleSmtpServer.java?diff_format=l&rev=1.8&view=auto
run() isn't called directly from start(port), instead a Thread is
created and started. The started thread calls run(), and hence the
method that calls start(port) will never see the IOException.
True?
Not true, but while I was writing this answer to you I noticed that
there's a bug inside the SimpleSmtpServer.run() method. Dumbster works
fine if the ServerSocket doesn't throw an exception but if it does, the
isStopped() method will still return false while it should return true.
I'll try to explain both the bug and the inner workings of the
SimpleSmtpServer.start().
SimpleSmtpServer implements the Runnable interface and in its start(int)
method a new instance of himself is passed to the Thread's constructor.
This means that when the Thread starts it will call
SimpleSmtpServer.run() that will try to instantiate a new ServerSocket
wich may throw an IOException. The notifyAll() is then called allowing
concurrent threads (in this case the commons-email TestCases) to run. If
any exception is thrown then it will be captured inside the run()
method, we'll see a stack trace of the problem and the run() method is over.
The problem is: if a socket cannot be opened the the server is not
running. There is no code setting the stopped variable to true inside
any catch block.
I'll suggest moving the first line of SimpleSmtpServer.run() ("stopped =
false") to somewhere after the instantiation of the ServerSocket (inside
the same method).
Anyway, it's not not a commons-email problem. We can still make the
change proposed bellow since the timeout checks won't do any workaround
to this bug inside dumbster.
Ramiro Pereira de Magalhães
You can read more about the ServerSocket(int) constructor here:
http://java.sun.com/j2se/1.5.0/docs/api/java/net/ServerSocket.html#ServerSocket(int)
Ramiro Pereira de Magalhães
Dion Gillard wrote:
What if Dumbster gets given a bad port number by commons email?
Did you just mean the timeout checks?
If so, can we just replace:
this.fakeMailServer =
SimpleSmtpServer.start(EmailConfiguration.MAIL_SERVER_PORT);
Date dtStartWait = new Date();
while (this.fakeMailServer.isStopped())
{
// test for connected
if (this.fakeMailServer != null
&& !this.fakeMailServer.isStopped())
{
break;
}
// test for timeout
if ((dtStartWait.getTime() + EmailConfiguration.TIME_OUT)
<= new Date().getTime())
{
fail("Mail server failed to start");
}
}
with:
this.fakeMailServer =
SimpleSmtpServer.start(EmailConfiguration.MAIL_SERVER_PORT);
if (this.fakeMailServer.isStopped()) fail("Mail server
failed to start");
?
On 6/27/05, Ramiro Pereira de Magalhaes <[EMAIL PROTECTED]> wrote:
Ramiro Pereira de Magalhaes wrote:
[EMAIL PROTECTED] wrote:
Author: dion
Date: Sat Jun 25 04:48:51 2005
New Revision: 201739
URL: http://svn.apache.org/viewcvs?rev=201739&view=rev
Log:
Move to dumbster 1.6 for testing:
- jdk13 compatible
- faster
- still works for us
Modified:
jakarta/commons/proper/email/trunk/project.xml
Modified: jakarta/commons/proper/email/trunk/project.xml
URL:
http://svn.apache.org/viewcvs/jakarta/commons/proper/email/trunk/project.xml?rev=201739&r1=201738&r2=201739&view=diff
==============================================================================
--- jakarta/commons/proper/email/trunk/project.xml (original)
+++ jakarta/commons/proper/email/trunk/project.xml Sat Jun 25
04:48:51 2005
@@ -152,7 +152,7 @@
<dependency>
<groupId>dumbster</groupId>
<artifactId>dumbster</artifactId>
- <version>1.5</version>
+ <version>1.6</version>
<properties/>
</dependency>
</dependencies>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
If you're using dumbster version 1.6 then check it out from CVS and
build it. There is a small but important difference between the code
on CVS and the code currently released that avoids some locks while
starting a SimpleSmtpServer. Check the difference here:
http://cvs.sourceforge.net/viewcvs.py/dumbster/dumbster/src/com/dumbster/smtp/SimpleSmtpServer.java?r1=1.7&r2=1.8
Ramiro Pereira de Magalhães
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I forgot to say that the getMailServer() method on BaseEmailTestCase
class performs unnecessary checks in order to be sure that dumbster mail
server's up. Dumbster itself takes care of it.
Ramiro Pereira de Magalhães
_______________________________________________________
Yahoo! Acesso Gr�tis - Internet r�pida e gr�tis.
Instale o discador agora! http://br.acesso.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_______________________________________________________
Yahoo! Acesso Gr�tis - Internet r�pida e gr�tis.
Instale o discador agora! http://br.acesso.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
_______________________________________________________
Yahoo! Acesso Gr�tis - Internet r�pida e gr�tis.
Instale o discador agora! http://br.acesso.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]