Cache in CelestialBodyFactory
The cache system you have implemented in the CelestialBodyFactory by means of the CELESTIAL_BODIES_MAP variable is giving me a hard time. The problem is that I add a loader and ask for a body. Then I remove all loaders and add a different loader. If I ask for the same body, I still get the body I would have gotten with the first loader. I would have expected the body created by the new loader.
As strange as this could be in a piece of code (using bodies, then removing their loaders, redefining them in a different way and asking for the same bodies again...), this situation arises easily in the testing process. I use jUnit as unit test tool. jUnit runs all the defined tests one after another in the same run, in an undefined order. I have two different tests, each of them using different ephemeris. If I run them separately, everything works. If I run them together, one of them fails because it uses the wrong bodies.
I was wondering, maybe you had this problem already? Do you have unitary tests with different loaders for the same bodies? How did you make them work?
In my opinion, there are two ways of solving this issue while keeping this body cache system:
- Everytime a loader is cleared, all the bodies created with this loader should be removed from CELESTIAL_BODIES_MAP, or
- Everytime a body is requested, check if its loader is still in. If not, remove it from CELESTIAL_BODIES_MAP and recalculate it.
Thanks for your support. You really are doing a very good work with Orekit.
(from redmine: issue id 106, created on 2012-07-23, closed on 2012-07-23)