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

        Nick Griffiths created issue -
        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.
        Nick Griffiths made changes -
        Field Original Value New Value
        Attachment remove-fail-available-check.diff [ 12456769 ]
        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.
        Nick Griffiths made changes -
        Attachment allow-init-fail-via-init-exception.diff [ 12456770 ]
        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 -

        get rid of reliance on Throwable#getCause

        Show
        Nick Griffiths added a comment - get rid of reliance on Throwable#getCause
        Nick Griffiths made changes -
        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!
        Mladen Turk made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        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.
        Sebb made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        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.
        Nick Griffiths made changes -
        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
        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.
        Mladen Turk made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        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
        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.
        Nick Griffiths made changes -
        Attachment simple-daemon-with-init-exception.diff [ 12457372 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        7d 3h 43m 1 Mladen Turk 16/Oct/10 15:59
        Resolved Resolved Reopened Reopened
        19h 47m 1 Sebb 17/Oct/10 11:47
        Reopened Reopened Resolved Resolved
        1h 15m 1 Mladen Turk 17/Oct/10 13:03

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development