Ole8700 / openhab

Automatically exported from code.google.com/p/openhab
GNU General Public License v3.0
1 stars 0 forks source link

Harden up Bindings Framework Code #208

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Due to an unhandled exception inside the homematic bindings 
allBindingsChanged/bindingChanged method, the whole openHAB system became 
unstable (device rescan every few seconds). This could occure with other 
bindings as well.

I would propose to make all important binding calls in a try - catch block. 
This avoids the situation that one problematic binding influences the whole 
openHAB system.

E.g. 
    private void notifyListeners(Item item) {
        for (BindingChangeListener listener : listeners) {
            listener.bindingChanged(this, item.getName());
        }
    }

to 
    private void notifyListeners(Item item) {
        for (BindingChangeListener listener : listeners) {
            try {
                listener.bindingChanged(this, item.getName());
            } catch (Exception e) {
                logger.error("Binding XY reacts incorrectly", e);
            }
        }
    }

Original issue reported on code.google.com by thomas.letsch.de on 12 Mar 2013 at 9:00

GoogleCodeExporter commented 9 years ago
Could you describe in more details what happened here if the exception wasn't 
caught (e.g. a stacktrace to understand where the exception bubbles up and 
hence impacts openHAB core functionality).

Original comment by kai.openhab on 14 Mar 2013 at 8:37

GoogleCodeExporter commented 9 years ago
It came from one Homematic tester. A few more details are in the issue:
https://code.google.com/p/openhab-homematic/issues/detail?id=25

Original comment by thomas.letsch.de on 14 Mar 2013 at 9:44

GoogleCodeExporter commented 9 years ago
Thanks, I have done the proposed change: 
https://code.google.com/p/openhab/source/detail?r=765b6624a8569713c9d5f995a37223
23a5ad4726

Original comment by kai.openhab on 15 Mar 2013 at 8:49