# HG changeset patch # User Omair Majid # Date 1393538433 18000 # Node ID cba7b8de5f760c9da6e45d2242df9d8376ca63dd # Parent fde496a78a985acf14117cd8fa6beb15d9b7b6bc Preserve class invariants after marshalling The violation of the invariant (commands and extensions being non-null) causes NullPointerExceptions when data is being read by the UI. This causes the relevant tab to not show up at all. diff -r fde496a78a98 -r cba7b8de5f76 com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/Plugin.java --- a/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/Plugin.java Thu Feb 27 15:40:52 2014 -0500 +++ b/com.redhat.thermostat.tools.eclipse.plugin/src/com/redhat/thermostat/tools/eclipse/plugin/model/Plugin.java Thu Feb 27 17:00:33 2014 -0500 @@ -115,6 +115,16 @@ } } + /** After marshalling empty list as no-element, recreate empty list so invariants still hold */ + void afterMarshal(Marshaller marshaller) { + if (this.commands == null) { + this.commands = new ArrayList<>(); + } + if (this.extensions == null) { + this.extensions = new ArrayList<>(); + } + } + /** If null elements were read, re-initialize to empty list */ void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { if (this.commands == null) {