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

NullPointerException not advertized in Javadoc

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.2
    • 4.0, 3.6
    • None
    • Mac OS 10.9, Java 6, 7

    Description

      The following statement produces a NullPointerException:

      new org.apache.commons.math3.optim.nonlinear.vector.jacobian.LevenbergMarquardtOptimizer().getWeight();

      The documentation does not seem to indicate that other data must be set before getWeight is used (at least I could not find that information). In this case, weightMatrix is still null because it has not been initialized.

      This call should probably throw an IllegalStateException, which makes it clear that this API usage is incorrect.

      This test uses LevenbergMarquardtOptimizer but any instantiable subclass of MultivariateVectorOptimizer probably works the same way.

      Attachments

        1. Report7.java
          0.2 kB
          Cyrille Artho
        2. Report6.java
          0.4 kB
          Cyrille Artho
        3. Report2.java
          0.2 kB
          Cyrille Artho
        4. IllegalStateB.java
          0.9 kB
          Cyrille Artho

        Activity

          People

            Unassigned Unassigned
            Telcontar Cyrille Artho
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: