You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@apache.org> on 2006/10/17 00:43:13 UTC

Incorrect code in NetworkDerbyControlImpl.shutdown()??

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?

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


Re: Incorrect code in NetworkDerbyControlImpl.shutdown()??

Posted by Knut Anders Hatlen <Kn...@Sun.COM>.
Daniel John Debrunner <dj...@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