Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.0.3
    • Fix Version/s: 1.0.4
    • Component/s: None
    • Labels:
      None
    • Environment:

      linux

      Description

      It would be handy to be able to fail with a nice message during init, such as 'database not available' or 'no config file found' or whatever.

      At the moment, if you try that during init, you get an IllegalStateException. I've attached a patch which removes this restriction in DaemonLoader, but failing at this stage doesn't stop the c code from calling start. I could work around this in the DaemonLoader, but not sure that is the right approach. I'll have a go at doing a patch for the c-code, but I'm not a confident in my c skills...

      1. simple-daemon-with-init-exception.diff
        0.6 kB
        Nick Griffiths
      2. remove-fail-available-check.diff
        2 kB
        Nick Griffiths
      3. allow-init-fail-via-init-exception-v3.diff
        6 kB
        Nick Griffiths
      4. allow-init-fail-via-init-exception-13.diff
        5 kB
        Nick Griffiths
      5. allow-init-fail-via-init-exception.diff
        5 kB
        Nick Griffiths

        Activity

        Hide
        Nick Griffiths added a comment -

        the diff of SimpleDaemon on top of r1023470 which shows an example of failing during initialisation.

        Show
        Nick Griffiths added a comment - the diff of SimpleDaemon on top of r1023470 which shows an example of failing during initialisation.
        Hide
        Nick Griffiths added a comment -

        Ah, just did it, but cheers anyway.

        Show
        Nick Griffiths added a comment - Ah, just did it, but cheers anyway.
        Hide
        Mladen Turk added a comment -

        Never mind. I modified the patch by hand. Thanks again.

        Show
        Mladen Turk added a comment - Never mind. I modified the patch by hand. Thanks again.
        Hide
        Mladen Turk added a comment -

        Can you make the patch for the current trunk?
        I already committed the previous version, so the new patch would only need a diff for that getCause().

        Show
        Mladen Turk added a comment - Can you make the patch for the current trunk? I already committed the previous version, so the new patch would only need a diff for that getCause().
        Hide
        Nick Griffiths added a comment -

        This time without getCause on InvocationTargetException (getTargetException instead) and modified SimpleDaemon example to use a DaemonInitException if it can't bind to its port.

        Show
        Nick Griffiths added a comment - This time without getCause on InvocationTargetException (getTargetException instead) and modified SimpleDaemon example to use a DaemonInitException if it can't bind to its port.
        Hide
        Sebb added a comment -

        Re-opening because as mentioned on the dev list, the code does not compile under Java 1.3 because DaemonLoader calls InvocationTargetException.getCause().

        Assuming that the above can be fixed, it would be useful to provide an example Daemon implementation that used DaemonInitException - or perhaps update one of the existing samples to throw it.

        Show
        Sebb added a comment - Re-opening because as mentioned on the dev list, the code does not compile under Java 1.3 because DaemonLoader calls InvocationTargetException.getCause(). Assuming that the above can be fixed, it would be useful to provide an example Daemon implementation that used DaemonInitException - or perhaps update one of the existing samples to throw it.
        Hide
        Mladen Turk added a comment -

        Applied to the trunk as r1023303.
        Thanks for the patch!

        Show
        Mladen Turk added a comment - Applied to the trunk as r1023303. Thanks for the patch!
        Hide
        Nick Griffiths added a comment -

        get rid of reliance on Throwable#getCause

        Show
        Nick Griffiths added a comment - get rid of reliance on Throwable#getCause
        Hide
        Mladen Turk added a comment -

        Daemon has JDK 1.3 as target. Throwable.getCause() is present in 1.4 onwards.

        Show
        Mladen Turk added a comment - Daemon has JDK 1.3 as target. Throwable.getCause() is present in 1.4 onwards.
        Hide
        Nick Griffiths added a comment -

        Expands on previous patch to handle failing during init with an DaemonInitException. this dumps the error message out using fail, and returns false from init to stop further start up.

        Show
        Nick Griffiths added a comment - Expands on previous patch to handle failing during init with an DaemonInitException. this dumps the error message out using fail, and returns false from init to stop further start up.
        Hide
        Nick Griffiths added a comment -

        removes the check for isAvailable in fail, to allow failing during init.

        Show
        Nick Griffiths added a comment - removes the check for isAvailable in fail, to allow failing during init.

          People

          • Assignee:
            Unassigned
            Reporter:
            Nick Griffiths
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development