commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cyrille Artho (JIRA)" <>
Subject [jira] [Commented] (MATH-1116) NullPointerException in MultivariateVectorOptimizer.getWeight()
Date Mon, 14 Apr 2014 23:35:15 GMT


Cyrille Artho commented on MATH-1116:

Thank you for the quick feedback.
There are a number of other classes that are not going to be deprecated in 3.3, which have
the same issue. For example, there are five cases where I have found a one-liner that shows
the problem:

    new org.apache.commons.math3.random.ValueServer().resetReplayFile();
    new org.apache.commons.math3.stat.regression.GLSMultipleLinearRegression().estimateErrorVariance();
    new org.apache.commons.math3.random.EmpiricalDistribution().getGeneratorUpperBounds();
    new org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression().calculateHat();
    new org.apache.commons.math3.stat.correlation.PearsonsCorrelation().getCorrelationStandardErrors();

I can post these in separate bug reports if there is interest, along with a few cases that
are multiple lines.

I think it would be good to do something about these cases:

(1) Deprecate the constructors that build incomplete instances, or
(2) throw an IllegalStateException or a NullPointerException with an error message ("xy needs
to be set"), or
(3) make the constructors non-public, or
(4) add a comment such as in NordSieckStepInterpolator:

That comment clearly puts the blame on the user if a NullPointerException happens. However,
it would be nice to have this also in the executable (as an exception message, perhaps).

> NullPointerException in MultivariateVectorOptimizer.getWeight()
> ---------------------------------------------------------------
>                 Key: MATH-1116
>                 URL:
>             Project: Commons Math
>          Issue Type: Bug
>    Affects Versions: 3.2
>         Environment: Mac OS 10.9, Java 6, 7
>            Reporter: Cyrille Artho
>         Attachments:
> 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.

This message was sent by Atlassian JIRA

View raw message