jchempaint icon indicating copy to clipboard operation
jchempaint copied to clipboard

better error handling in IsotopeFactory.java

Open rwst opened this issue 12 years ago • 2 comments

This is with the 3.3 application from ebi and the icedtea7 vm every time an atom is selected when inputting "cooh"

java.lang.NullPointerException at org.openscience.cdk.config.IsotopeFactory.configure(IsotopeFactory.java:347) at org.openscience.cdk.config.IsotopeFactory.configure(IsotopeFactory.java:332) at org.openscience.jchempaint.controller.ControllerHub.setSymbol(ControllerHub.java:980) at org.openscience.jchempaint.JChemPaintPanel.keyReleased(JChemPaintPanel.java:352) at java.awt.Component.processKeyEvent(Component.java:6466) at javax.swing.JComponent.processKeyEvent(JComponent.java:2820) at java.awt.Component.processEvent(Component.java:6282) at java.awt.Container.processEvent(Container.java:2229) at java.awt.Component.dispatchEventImpl(Component.java:4861) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1890) at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:752) at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1017) at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:889) at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:717) at java.awt.Component.dispatchEventImpl(Component.java:4731) at java.awt.Container.dispatchEventImpl(Container.java:2287) at java.awt.Window.dispatchEventImpl(Window.java:2713) at java.awt.Component.dispatchEvent(Component.java:4687) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707) at java.awt.EventQueue.access$000(EventQueue.java:101) at java.awt.EventQueue$3.run(EventQueue.java:666) at java.awt.EventQueue$3.run(EventQueue.java:664) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87) at java.awt.EventQueue$4.run(EventQueue.java:680) at java.awt.EventQueue$4.run(EventQueue.java:678) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) at java.awt.EventQueue.dispatchEvent(EventQueue.java:677) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

rwst avatar May 23 '12 15:05 rwst

reason is: on the first atom change the mass number is set from getMajorIsotope() but with the second change we assume the mass number set and try to get that new isotope. so, if we key C followed by H it tries to find a 12H isotope which does not exist, of course.

the second bug is that non-existing isotopes should give an error message, not an exception.

rwst avatar May 25 '12 10:05 rwst

crash is fixed, leaving the better error handling as enhancement

rwst avatar May 25 '12 14:05 rwst