Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the SPIMAcquisition code substantially by introducing well-needed defensive programming #15

Open
dscho opened this issue Apr 20, 2015 · 0 comments
Assignees

Comments

@dscho
Copy link
Contributor

dscho commented Apr 20, 2015

Even a brief test failed to bring up the SPIM Acquisition GUI with a demo device-based system here. At first, an error was shown that it needs a 4D stage, but starting the SPIM Acquisition plugin again after configuring an extra DStage (for rotation) and an extra DXYStage, it greeted me with:

2015-04-20T16:00:39.098369 tid139811919632128 [IFO,App] Thread 29 (AWT-EventQueue-0) terminated with uncaught exception
2015-04-20T16:00:39.098382 tid139811919632128 [IFO,App] java.lang.NullPointerException
2015-04-20T16:00:39.098632 tid139811919632128 [IFO,App]   at spim.SPIMAcquisition.updateUI(SPIMAcquisition.java:1183)
2015-04-20T16:00:39.098643 tid139811919632128 [IFO,App]   at spim.SPIMAcquisition.configurationChanged(SPIMAcquisition.java:304)
2015-04-20T16:00:39.098650 tid139811919632128 [IFO,App]   at spim.SPIMAcquisition.show(SPIMAcquisition.java:219)
2015-04-20T16:00:39.098659 tid139811919632128 [IFO,App]   at org.micromanager.pluginmanagement.PluginManager.displayPlugin(PluginManager.java:114)
2015-04-20T16:00:39.098666 tid139811919632128 [IFO,App]   at org.micromanager.pluginmanagement.PluginManager.access$100(PluginManager.java:22)
2015-04-20T16:00:39.098674 tid139811919632128 [IFO,App]   at org.micromanager.pluginmanagement.PluginManager$2.run(PluginManager.java:64)
2015-04-20T16:00:39.098682 tid139811919632128 [IFO,App]   at org.micromanager.utils.GUIUtils$3.actionPerformed(GUIUtils.java:339)
2015-04-20T16:00:39.098691 tid139811919632128 [IFO,App]   at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
2015-04-20T16:00:39.098699 tid139811919632128 [IFO,App]   at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
2015-04-20T16:00:39.098707 tid139811919632128 [IFO,App]   at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
2015-04-20T16:00:39.098715 tid139811919632128 [IFO,App]   at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
2015-04-20T16:00:39.098722 tid139811919632128 [IFO,App]   at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
2015-04-20T16:00:39.098730 tid139811919632128 [IFO,App]   at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:809)
2015-04-20T16:00:39.098738 tid139811919632128 [IFO,App]   at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:850)
2015-04-20T16:00:39.098746 tid139811919632128 [IFO,App]   at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:272)
2015-04-20T16:00:39.098754 tid139811919632128 [IFO,App]   at java.awt.Component.processMouseEvent(Component.java:6289)
2015-04-20T16:00:39.098762 tid139811919632128 [IFO,App]   at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
2015-04-20T16:00:39.098770 tid139811919632128 [IFO,App]   at java.awt.Component.processEvent(Component.java:6054)
2015-04-20T16:00:39.098778 tid139811919632128 [IFO,App]   at java.awt.Container.processEvent(Container.java:2041)
2015-04-20T16:00:39.098786 tid139811919632128 [IFO,App]   at java.awt.Component.dispatchEventImpl(Component.java:4652)
2015-04-20T16:00:39.098799 tid139811919632128 [IFO,App]   at java.awt.Container.dispatchEventImpl(Container.java:2099)
2015-04-20T16:00:39.098808 tid139811919632128 [IFO,App]   at java.awt.Component.dispatchEvent(Component.java:4482)
2015-04-20T16:00:39.098816 tid139811919632128 [IFO,App]   at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577)
2015-04-20T16:00:39.098824 tid139811919632128 [IFO,App]   at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
2015-04-20T16:00:39.098832 tid139811919632128 [IFO,App]   at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
2015-04-20T16:00:39.098840 tid139811919632128 [IFO,App]   at java.awt.Container.dispatchEventImpl(Container.java:2085)
2015-04-20T16:00:39.098848 tid139811919632128 [IFO,App]   at java.awt.Window.dispatchEventImpl(Window.java:2478)
2015-04-20T16:00:39.098855 tid139811919632128 [IFO,App]   at java.awt.Component.dispatchEvent(Component.java:4482)
2015-04-20T16:00:39.098863 tid139811919632128 [IFO,App]   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
2015-04-20T16:00:39.098870 tid139811919632128 [IFO,App]   at java.awt.EventQueue.access$000(EventQueue.java:85)
2015-04-20T16:00:39.098878 tid139811919632128 [IFO,App]   at java.awt.EventQueue$1.run(EventQueue.java:603)
2015-04-20T16:00:39.098885 tid139811919632128 [IFO,App]   at java.awt.EventQueue$1.run(EventQueue.java:601)
2015-04-20T16:00:39.098890 tid139811919632128 [IFO,App]   at java.security.AccessController.doPrivileged(Native Method)
2015-04-20T16:00:39.098898 tid139811919632128 [IFO,App]   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
2015-04-20T16:00:39.098906 tid139811919632128 [IFO,App]   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
2015-04-20T16:00:39.098913 tid139811919632128 [IFO,App]   at java.awt.EventQueue$2.run(EventQueue.java:617)
2015-04-20T16:00:39.098920 tid139811919632128 [IFO,App]   at java.awt.EventQueue$2.run(EventQueue.java:615)
2015-04-20T16:00:39.098925 tid139811919632128 [IFO,App]   at java.security.AccessController.doPrivileged(Native Method)
2015-04-20T16:00:39.098932 tid139811919632128 [IFO,App]   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
2015-04-20T16:00:39.098940 tid139811919632128 [IFO,App]   at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
2015-04-20T16:00:39.098947 tid139811919632128 [IFO,App]   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
2015-04-20T16:00:39.098955 tid139811919632128 [IFO,App]   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
2015-04-20T16:00:39.098963 tid139811919632128 [IFO,App]   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
2015-04-20T16:00:39.098970 tid139811919632128 [IFO,App]   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
2015-04-20T16:00:39.098977 tid139811919632128 [IFO,App]   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
2015-04-20T16:00:39.098985 tid139811919632128 [IFO,App]   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

This is a clear indicator that the code makes too many incorrect assumptions about the current state. Even worse, trying to shut down Micro-Manager in order to restart only resulted in this message:

2015-04-20T16:02:11.331182 tid139813670328064 [IFO,App] Thread 30 (AWT-EventQueue-0) terminated with uncaught exception
2015-04-20T16:02:11.331200 tid139813670328064 [IFO,App] java.lang.NullPointerException
2015-04-20T16:02:11.331397 tid139813670328064 [IFO,App]   at spim.SPIMAcquisition.dispose(SPIMAcquisition.java:189)
2015-04-20T16:02:11.331407 tid139813670328064 [IFO,App]   at org.micromanager.pluginmanagement.PluginItem.dispose(PluginItem.java:111)
2015-04-20T16:02:11.331414 tid139813670328064 [IFO,App]   at org.micromanager.pluginmanagement.PluginLoader.disposePlugins(PluginLoader.java:248)
2015-04-20T16:02:11.331421 tid139813670328064 [IFO,App]   at org.micromanager.pluginmanagement.PluginManager.disposePlugins(PluginManager.java:143)
2015-04-20T16:02:11.331430 tid139813670328064 [IFO,App]   at org.micromanager.MMStudio.cleanupOnClose(MMStudio.java:1562)
2015-04-20T16:02:11.331438 tid139813670328064 [IFO,App]   at org.micromanager.MMStudio.closeSequence(MMStudio.java:1623)
2015-04-20T16:02:11.331446 tid139813670328064 [IFO,App]   at org.micromanager.MainFrame$1.windowClosing(MainFrame.java:159)
2015-04-20T16:02:11.331455 tid139813670328064 [IFO,App]   at java.awt.AWTEventMulticaster.windowClosing(AWTEventMulticaster.java:332)
2015-04-20T16:02:11.331462 tid139813670328064 [IFO,App]   at java.awt.AWTEventMulticaster.windowClosing(AWTEventMulticaster.java:332)
2015-04-20T16:02:11.331470 tid139813670328064 [IFO,App]   at java.awt.Window.processWindowEvent(Window.java:1865)
2015-04-20T16:02:11.331476 tid139813670328064 [IFO,App]   at javax.swing.JFrame.processWindowEvent(JFrame.java:274)
2015-04-20T16:02:11.331480 tid139813670328064 [IFO,App]   at java.awt.Window.processEvent(Window.java:1823)
2015-04-20T16:02:11.331485 tid139813670328064 [IFO,App]   at java.awt.Component.dispatchEventImpl(Component.java:4652)
2015-04-20T16:02:11.331489 tid139813670328064 [IFO,App]   at java.awt.Container.dispatchEventImpl(Container.java:2099)
2015-04-20T16:02:11.331493 tid139813670328064 [IFO,App]   at java.awt.Window.dispatchEventImpl(Window.java:2478)
2015-04-20T16:02:11.331497 tid139813670328064 [IFO,App]   at java.awt.Component.dispatchEvent(Component.java:4482)
2015-04-20T16:02:11.331502 tid139813670328064 [IFO,App]   at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:644)
2015-04-20T16:02:11.331505 tid139813670328064 [IFO,App]   at java.awt.EventQueue.access$000(EventQueue.java:85)
2015-04-20T16:02:11.331509 tid139813670328064 [IFO,App]   at java.awt.EventQueue$1.run(EventQueue.java:603)
2015-04-20T16:02:11.331513 tid139813670328064 [IFO,App]   at java.awt.EventQueue$1.run(EventQueue.java:601)
2015-04-20T16:02:11.331516 tid139813670328064 [IFO,App]   at java.security.AccessController.doPrivileged(Native Method)
2015-04-20T16:02:11.331520 tid139813670328064 [IFO,App]   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
2015-04-20T16:02:11.331524 tid139813670328064 [IFO,App]   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
2015-04-20T16:02:11.331528 tid139813670328064 [IFO,App]   at java.awt.EventQueue$2.run(EventQueue.java:617)
2015-04-20T16:02:11.331532 tid139813670328064 [IFO,App]   at java.awt.EventQueue$2.run(EventQueue.java:615)
2015-04-20T16:02:11.331535 tid139813670328064 [IFO,App]   at java.security.AccessController.doPrivileged(Native Method)
2015-04-20T16:02:11.331539 tid139813670328064 [IFO,App]   at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
2015-04-20T16:02:11.331543 tid139813670328064 [IFO,App]   at java.awt.EventQueue.dispatchEvent(EventQueue.java:614)
2015-04-20T16:02:11.331547 tid139813670328064 [IFO,App]   at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
2015-04-20T16:02:11.331551 tid139813670328064 [IFO,App]   at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
2015-04-20T16:02:11.331556 tid139813670328064 [IFO,App]   at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
2015-04-20T16:02:11.331560 tid139813670328064 [IFO,App]   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
2015-04-20T16:02:11.331564 tid139813670328064 [IFO,App]   at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
2015-04-20T16:02:11.331567 tid139813670328064 [IFO,App]   at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

The worst part is that these failures are only reported on the console. This is something this developer will see because he is a command line junkie. Regular end users will just see that nothing happened, which is the worst feedback a user interface can provide, even worse than a crash.

It will need at least more defensive programming, hopefully we will be able to refactor the code into much cleanlier separated parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants