Non-checked exception in a plugin: silently ignored

Hi, I just got a hard time with a problem with a plugin. This is a workspace plugin which installs a button in its own toolbar. After some changes, it started behaving like it was not properly fired when clicking on it. It turned out, after some debugging, it was because a null pointer exception was thrown, but silently ignored, regardless the level of logging. Maybe it would be nice to log such errors, or to provide an option to increase such checks if they have some cost, or to provide an oXygen-specific Swing action which does such checks and reporting. Regards, -- Florent Georges http://fgeorges.org/

Hi Florent, You probably had the code throwing the NullPointerException executed when a button was pressed. In this case the AWT Event Queue Thread complains directly in the "System.err" so if you run Oxygen using the startup scripts you should get in the console something like: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at ro.sync.sample.plugin.workspace.CustomWorkspaceAccessPluginExtension$2.actionPerformed(CustomWorkspaceAccessPluginExtension.java:154) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) It's more flexible for the API to allow you to add your own Swing buttons, actions and components to toolbars and views than to offer a lot of wrapper objects over the Swing *objects*. This allows someone knowing Java Swing to develop plugins more quickly. Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 1/24/2011 8:46 PM, Florent Georges wrote:
Hi,
I just got a hard time with a problem with a plugin. This is a workspace plugin which installs a button in its own toolbar. After some changes, it started behaving like it was not properly fired when clicking on it. It turned out, after some debugging, it was because a null pointer exception was thrown, but silently ignored, regardless the level of logging.
Maybe it would be nice to log such errors, or to provide an option to increase such checks if they have some cost, or to provide an oXygen-specific Swing action which does such checks and reporting.
Regards,

Radu Coravu wrote: Hi,
It's more flexible for the API to allow you to add your own Swing buttons, actions and components to toolbars and views than to offer a lot of wrapper objects over the Swing *objects*. This allows someone knowing Java Swing to develop plugins more quickly.
Oh yes, we agree on that. I love the fact oXygen is giving the Swing objects directly available to plugin developers. Just maybe it would be worth adding an OxygenAction, which would add to an AbstractAction some oXygen-related tools (like an error dialog just saying "Plugin unexpected error" or something like that). Regards, -- Florent Georges http://fgeorges.org/

Hi Florent, Thanks for the suggestion, I added it as an improvement request. By the way, if you are also using Apache Log4j and use the "logger.fatal" to log problems a special Errors dialog will pop-up to present them. So you can create your own AbstractAction wrapper which catches all Throwables and uses "logger.fatal" to report them. Regards, Radu Radu Coravu <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 1/25/2011 11:09 PM, Florent Georges wrote:
Radu Coravu wrote:
Hi,
It's more flexible for the API to allow you to add your own Swing buttons, actions and components to toolbars and views than to offer a lot of wrapper objects over the Swing *objects*. This allows someone knowing Java Swing to develop plugins more quickly. Oh yes, we agree on that. I love the fact oXygen is giving the Swing objects directly available to plugin developers. Just maybe it would be worth adding an OxygenAction, which would add to an AbstractAction some oXygen-related tools (like an error dialog just saying "Plugin unexpected error" or something like that).
Regards,

Radu Coravu wrote:
Thanks for the suggestion, I added it as an improvement request.
Good!
By the way, if you are also using Apache Log4j and use the "logger.fatal" to log problems a special Errors dialog will pop-up to present them. So you can create your own AbstractAction wrapper which catches all Throwables and uses "logger.fatal" to report them.
Yes, that's more or less what I do. Since I am writing a workspace access plugin, I use the standalone plugin workspace object instead, to show dialog boxes, but that's the same idea. Thanks for the help, -- Florent Georges http://fgeorges.org/
participants (2)
-
Florent Georges
-
Radu Coravu