NullPointerException when propagating multiple kind of propagator with any AdditionalStateProvider
Problem
When propagating an ephemeris, which was generated from a NumericalPropagator with a StateCovarianceMatrixProvider, a NullPointerException is thrown.
From the stack trace, we can see that this happens because when the ephemeris begins the propagation, the method AbstractPropagator.initializeAdditionalStates()
is called and initialize every additional states with the AbstractPropagator.initialState
attribute.
However when generated, the AbstractPropagator.initialState
attribute is out of reach of the Ephemeris constructor (as it is private and not final/protected etc), which causes the initialState to stay empty.
You'll find attached a unit test that reproduce the error with a StateCovarianceMatrixProvider but given the nature of the problem, it should happen with any kind of AdditionalStateProvider that has its own init()
method defined.
NullPointerExceptionEphemerisTest.java
Update
After further research i found that for some other inheritors of AbstractAnalyticalPropagator, they initialize the AbstractPropagator.initialState
attribute by using the super.resetInitialState method in their constructor. Currently, i found these propagators which should have the same problem as Ephemeris as they don't initialize their AbstractPropagator.initialState
attribute in their constructor :
- Ephemeris
- IntegratedEphemeris
- AdapterPropagator
- GLONASSAnalyticalPropagator
- GNSSPropagator
- SBASPropagator
For classes that already have some sort of custom getInitialState()
(overriding the parent one) such as IntegratedEphemeris, the solution is simple as we only need to add a super.resetInitialState(getInitialState)
in their constructor. However the others need to have their own getInitialState()
method before thinking of using this fix. For now, i'm working on a merge request that will hopefully fix the problem for all these classes.