db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Knut Anders Hatlen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-1465) NetworkServerControl.start() should throw an exception and not just print exceptions if the server fails to start
Date Tue, 16 Dec 2008 16:32:44 GMT

    [ https://issues.apache.org/jira/browse/DERBY-1465?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12657045#action_12657045
] 

Knut Anders Hatlen commented on DERBY-1465:
-------------------------------------------

In patch 6, completedBoot is set to true in the catch block in
startNetworkServer() after consolePropertyMessage() has been
called. If I understand the code in consolePropertyMessage()
correctly, it will in many cases throw an exception in addition to
printing a message to the console, in which case completedBoot is not
set to true. And I guess notifyAll() would have to be called there as
well.

Should completedBoot also be reset when runtimeException is reset?

Perhaps this is a more robust approach:

  1) Remove the runtimeException instance variable, and don't set it
     in blockingStart()

  2) Move the setting of completedBoot out of the finally block in
  blockingStart(), and don't set it in startNetworkServer(), so that
  it's only set if there was no error

  3) Put this in the start() method:

    completedBoot = false; // reset before we boot
    final Exception[] exceptionHolder = new Exception[1];
    .
    .
    .
    Thread t = new Thread("NetworkServerControl") {
        public void run() {
            try {
                blockingStart(consoleWriter);
            } catch (Exception e) {
                synchronized (serverStartComplete) {
                    exceptionHolder[0] = e;
                    serverStartComplete.notifyAll();
                }
            }
        }
    };
    .
    .
    .
    t.start();
    // wait until the server has started successfully
    // or an error has been detected
    synchronized (serverStartComplete) {
        while (!completedBoot && exceptionHolder[0] == null) {
            serverStartComplete.wait();
        }
    }
    if (!completedBoot) {
        // boot was not successful, throw the exception
        throw exceptionHolder[0];
    }

With this approach, we make the tracking of the exception simpler (all
exception handling is local to the start() method), and since
completedBoot is only set on successful boot, we don't need to track
down all error paths where it needs to be set.

> NetworkServerControl.start() should throw an exception and not just  print  exceptions
 if the server fails to start
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-1465
>                 URL: https://issues.apache.org/jira/browse/DERBY-1465
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Server
>    Affects Versions: 10.1.2.1
>            Reporter: Kathey Marsden
>            Priority: Minor
>         Attachments: DERBY-1465.diff3, DERBY-1465.diff4, DERBY-1465.diff5, DERBY-1465.diff6,
DERBY-1465_diff.txt, DERBY-1465_diff.txt, DERBY-1465_stat.txt, DERBY-1465_stat.txt, releaseNote.html,
releaseNote.html, releaseNote.html
>
>
> NetworkServerControl.start()  will not throw an exception  if another server is already
running on the same port.    I am not sure but think perhaps this was changed at  one point
to accomodate the derby.drda.startNetworkServer property  so that the embedded server could
continue to boot even if the network server failed to start, but  I think this is wrong for
normal usage.
> http://www.nabble.com/Questions-about-Network-Server-API-Behavior-p5055814.html

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message