Skip to content

QPT NullPointerException(s) #1497

Open
Open

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.

Activity

  1. swalker2m commented on May 9, 2018

    @swalker2m
    ContributorAuthor

    Stack traces:

    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at edu.gemini.qpt.ui.view.candidate.CandidateObsController.getSubElement(CandidateObsController.java:23)
    	at edu.gemini.qpt.ui.view.candidate.CandidateObsController.getSubElement(CandidateObsController.java:12)
    	at edu.gemini.ui.gface.GTableViewer$ImmutableTableModel.getValueAt(GTableViewer.java:289)
    	at javax.swing.JTable.getValueAt(JTable.java:2717)
    	at javax.swing.JTable.prepareRenderer(JTable.java:5706)
    	at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:2114)
    	at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:2016)
    	at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:1812)
    	at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
    	at javax.swing.JComponent.paintComponent(JComponent.java:780)
    	at javax.swing.JComponent.paint(JComponent.java:1056)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JViewport.paint(JViewport.java:728)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
    	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
    	at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
    	at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
    	at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
    	at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
    	at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
    	at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
    	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at edu.gemini.qpt.ui.view.visualizer.Visualizer.getMoonCurve(Visualizer.java:777)
    	at edu.gemini.qpt.ui.view.visualizer.Visualizer.paintMoon(Visualizer.java:489)
    	at edu.gemini.qpt.ui.view.visualizer.Visualizer.paint(Visualizer.java:169)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
    	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
    	at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
    	at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
    	at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
    	at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
    	at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
    	at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
    	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    	at edu.gemini.qpt.ui.view.visualizer.Visualizer.getElevationCurve(Visualizer.java:703)
    	at edu.gemini.qpt.ui.view.visualizer.Visualizer.paint(Visualizer.java:179)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
    	at javax.swing.JComponent.paintChildren(JComponent.java:889)
    	at javax.swing.JComponent.paint(JComponent.java:1065)
    	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
    	at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
    	at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
    	at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
    	at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
    	at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
    	at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
    	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
    	at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
    	at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
    	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    	at java.awt.EventQueue.access$500(EventQueue.java:97)
    	at java.awt.EventQueue$3.run(EventQueue.java:709)
    	at java.awt.EventQueue$3.run(EventQueue.java:703)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
    
  2. tpolecat commented on May 9, 2018

    @tpolecat
    Member

    It's been a while but I think the model is null when no plan is open, and may be momentarily null when refreshing from the database. Are you seeing this when there's definitely a plan open?

  3. swalker2m commented on May 10, 2018

    @swalker2m
    ContributorAuthor

    Are you seeing this when there's definitely a plan open?

    Yes, on refresh.

  4. tpolecat commented on May 10, 2018

    @tpolecat
    Member

    Yep, ok. In any case you're right about using Option. Assuming our glorious future includes QPT in its current form we will need to put in some effort modernizing the client code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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