Menu

#10 Dumbster fails to inform if it's stopped or not

open
None
5
2005-07-13
2005-06-28
Anonymous
No

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 the bug.

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 suggest moving the first line of
SimpleSmtpServer.run() ("stopped = false") to somewhere
after the instantiation of the ServerSocket (inside the
same method).

Ramiro Pereira de Magalhăes

Discussion

  • Jason Kitchen

    Jason Kitchen - 2005-07-13

    Logged In: YES
    user_id=752825

    Thanks for researching and finding a solution. Will
    integrate this into the next release.

     
  • Jason Kitchen

    Jason Kitchen - 2005-07-13
    • assigned_to: nobody --> jasonkitchen
     
  • David D. Kilzer

    David D. Kilzer - 2006-04-25

    Logged In: YES
    user_id=84089

    Perhaps the SimpleSmtpServer.start() methods could also
    return a null value if the server failed to start up, e.g.,
    due to the socket already being bound. The start() methods
    really shouldn't return an invalid object.

     
  • David D. Kilzer

    David D. Kilzer - 2006-04-25

    Logged In: YES
    user_id=84089

    See Patch 1476278 (Fix for Bug 1229248...fails to inform if
    it's stopped or not) for a fix.

    http://sourceforge.net/tracker/index.php?func=detail&aid=1476278&group_id=78413&atid=553188

    Wouldn't it be nice if SourceForge had proper attachment
    management so I could actually upload a patch to THIS
    tracker item?

     

Log in to post a comment.