Derby
  1. Derby
  2. DERBY-4665

Unidiomatic error handling in TimestampArithTest

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 10.7.1.1
    • Fix Version/s: 10.7.1.1
    • Component/s: Test
    • Labels:
      None

      Description

      TimestampArithTest contains some error handling code that prevents the underlying error from being reported to the JUnit framework, and it may even terminate the JVM running the tests on some errors. Examples:

      This code prints the stack trace of the underlying error to the terminal, but it won't be included in the report from the JUnit framework:

      printStackTrace(sqle);
      fail("Unexpected exception from statement '" + sql + "'");

      This code terminates the JVM on error, preventing subsequent tests from running, and also preventing the JUnit framework to report the results from the tests that did run:

      } catch (Exception e)

      { System.out.println(s + " is not a proper timestamp string."); System.out.println(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(); System.exit(1); return null; }
      1. errors2.diff
        5 kB
        Knut Anders Hatlen
      2. errors.diff
        3 kB
        Knut Anders Hatlen

        Activity

        Hide
        Knut Anders Hatlen added a comment -

        The attached patch makes the code stop printing the errors, and instead lets the exceptions propagate to the JUnit framework, either by removing try/catch or by using helper methods that preserve the original exception.

        Show
        Knut Anders Hatlen added a comment - The attached patch makes the code stop printing the errors, and instead lets the exceptions propagate to the JUnit framework, either by removing try/catch or by using helper methods that preserve the original exception.
        Hide
        Kristian Waagan added a comment -

        +1 to commit 'errors.diff'

        It seems the label passed in to expectNullResult is no longer printed in the case of a failure, but that shouldn't be much of a problem. Possible improvements could be to either add a println or turn the labels into comments.

        Show
        Kristian Waagan added a comment - +1 to commit 'errors.diff' It seems the label passed in to expectNullResult is no longer printed in the case of a failure, but that shouldn't be much of a problem. Possible improvements could be to either add a println or turn the labels into comments.
        Hide
        Knut Anders Hatlen added a comment -

        Thanks for looking at the patch, Kristian.

        I've uploaded a new patch, where the labels have been turned into comments. I don't think they need to be printed, since it should be easy to see which sub-test failed by looking at the stack traces.

        Committed revision 946188.

        Show
        Knut Anders Hatlen added a comment - Thanks for looking at the patch, Kristian. I've uploaded a new patch, where the labels have been turned into comments. I don't think they need to be printed, since it should be easy to see which sub-test failed by looking at the stack traces. Committed revision 946188.

          People

          • Assignee:
            Knut Anders Hatlen
            Reporter:
            Knut Anders Hatlen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development