Uploaded image for project: 'Derby'
  1. Derby
  2. DERBY-6695

Improving configuration code: should not silently replace an invalid value with the default one

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 10.10.1.1
    • Fix Version/s: None
    • Component/s: Miscellaneous
    • Environment:
      All envrionments
    • Issue & fix info:
      Known fix
    • Bug behavior facts:
      Deviation from standard, Wrong query result

      Description

      Dear Derby developers,

      I have been using Derby for a while, and think the configuration handling code should be improved. In particular, Derby should check the validity of a user-specified configuration value, rather than replacing an invalid value with the default.

      Not sure that is a major issue or not. But at least it happens to me a couple of times, and causes lots of confusion. Thus, I strongly suggest to fix this.

      How to reproduce the problem.

      set:

      derby.storage.pageSize= l2800 ( note the first char is "l" (L), not "1")

      clearly, this invalid value should be notified immediately (or at least logged), however, Derby simply replaces that with the default value, which seems to be "32768". This is a real example, and causes confusion.

      I looked at the code and found the improving code:

      In class PropertyUtil

      public static int handleInt(String value, int min, int max, int defaultValue) {

      if (value == null)
      return defaultValue;

      try

      { int intValue = Integer.parseInt(value); if ((intValue >= min) && (intValue <= max)) return intValue; }

      catch (NumberFormatException nfe)

      { // just leave the default. }

      return defaultValue;
      }

      I would suggest to add logging statements for the invalid cases, and produce an error message to indicate which configuration value is incorrect.

      I have a few more such cases, if you are interested in improving the code, I am happy to share that too.

      Please let me know your thought.

      -Sai

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                szhang Sai Zhang
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 5m
                  5m
                  Remaining:
                  Remaining Estimate - 5m
                  5m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified