Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-1419

Invalid usage of exception in PolynomialSplineFunction

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 3.6.1
    • 4.0
    • None

    Description

      In PolynomialSplineFunction constructor, it tests whether length of knots is smaller than 2 or not. If <2, it throws NumberIsTooSmallException like below:

      if (knots.length < 2) {
          throw new NumberIsTooSmallException(LocalizedFormats.NOT_ENOUGH_POINTS_IN_SPLINE_PARTITION,
                                                                     2, knots.length, false);
              }
      

      But definition of above exception has parameters of the form:

      /**
       * Construct the exception with a specific context.
       *
       * @param specific Specific context pattern.
       * @param wrong Value that is smaller than the minimum.
       * @param min Minimum.
       * @param boundIsAllowed Whether {@code min} is included in the allowed range.
       */
      public NumberIsTooSmallException(Localizable specific,
                                       Number wrong,
                                       Number min,
                                       boolean boundIsAllowed) {
          super(specific, wrong, min);
      
          this.min = min;
          this.boundIsAllowed = boundIsAllowed;
      }
      

      In my opinion, 2, knots.length, false should be knots.length, 2, true

      since 2 is the minimum value and knots.length is the wrong value in this case. Moreover, boolean should be set by true because 2 is also acceptable.

      Attachments

        Activity

          People

            Unassigned Unassigned
            hangpark Hang Park
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

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