Skip to content

QPT NullPointerException(s) #1497

Description

@swalker2m

A number of us, very much including myself, have modified the QPT over the years without really knowing what we're doing. Likely as a consequence, it's pretty easy to see NPEs scroll by as you use the QPT. I can't detect any issue in the UI itself as a result, but it is disconcerting.

The issue appears to be assuming a model is available when it isn't for some reason. For example in the CandidateObsController:

	public synchronized Object getSubElement(Obs obs, CandidateObsAttribute subElement) {
		switch (subElement) {
...
		case RA: return obs.getRa(viewer.getModel().getMiddlePoint());
...
		}
		return null;
	}

Getting the RA will sometimes throw a NPE because viewer.getModel() is null.

Other examples in Visualizer:

	private Shape getMoonCurve(long start, long end) {
		synchronized (cacheLock) {

			// Try to use the cached version if we can.
...
			// Cache lookup failed, oh well. Calculate the moon's path.
			ImprovedSkyCalc calc = new ImprovedSkyCalc(model.getSchedule().getSite());

sometimes is surprised to find a null model. Similarly in getElevationCurve:

	private Shape getElevationCurve(Function<Long, WorldCoords> coords, long start, long end, boolean close, String obsId, Map<String, CachedShape> cache) {
		synchronized (cacheLock) {

			// Return the cached shape, if any.
...
			// Otherwise build the shape.
			ImprovedSkyCalc calc = new ImprovedSkyCalc(model.getSchedule().getSite());

Since the model may not be there when you need it, most of these methods could be edited to return an Option<Foo> but perhaps the real issue is that the model should always be there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions