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

HarmonicCoefficientsGuesser.sortObservations() potentlal NPE warning

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.2, 3.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      HarmonicCoefficientsGuesser.sortObservations()

      generates an NPE warning from Eclipse which thinks that mI can be null in the while condition.

      The code looks like:

      WeightedObservedPoint mI = observations[i];
      while ((i >= 0) && (curr.getX() < mI.getX())) {
          observations[i + 1] = mI;
          if (i-- != 0) {
              mI = observations[i];
          } else {
              mI = null;
          }
      }
      // mI is not used further
      

      It looks to me as though the "mI = null" statement is either redundant or wrong - why would one want to replace one of the observations with null during a sort?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sebb Sebb
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: