db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Incorrect code in NetworkDerbyControlImpl.shutdown()??
Date Tue, 17 Oct 2006 05:55:08 GMT
Daniel John Debrunner <djd@apache.org> writes:

> In NetworkDerbyControlImpl.shutdown() there is code that logs the
> message "DRDA_ShutdownError.S", which is:
>
> Unable to shutdown server on port  {0} on host {1}.
>
> The position of the code looks wrong, it is in a catch block for an
> exception with an if statement to check that the server has looped
> through SHUTDOWN_CHECK_ATTEMPTS.
>
> It seems that really the intention of the code would mean it should be
> logged outside the loop. See the following extracted code, it seems to
> me the code between the MOVE and END-MOVE comments should be moved to
> the end, where the TO-HERE comment is?

I agree. (ntry == SHUTDOWN_CHECK_ATTEMPTS) is always false inside the
loop, so the message is never printed. Moving the code as you
suggested sounds fine. Then the message will be printed if and only if
ping() has returned successfully SHUTDOWN_CHECK_ATTEMPTS times, which
seems to be the intention.

> Dan.
>
> int ntry;
> for (ntry = 0; ntry < SHUTDOWN_CHECK_ATTEMPTS; ntry++)
> {
>    Thread.sleep(SHUTDOWN_CHECK_INTERVAL);
>    try {
>      ping();
>    } catch (Exception e)
>    {
>      // as soon as we can't ping return
>      // MOVE
>      if (ntry == SHUTDOWN_CHECK_ATTEMPTS)
> 	consolePropertyMessage("DRDA_ShutdownError.S", new String [] {
> 		Integer.toString(portNumber), hostArg});
>      // END-MOVE
>      break;
>    }
> }
> // TO-HERE

-- 
Knut Anders

Mime
View raw message