- logger.warn("Unable to restore configuration snapshot from {}", file, e);
- throw new IllegalStateException("Unable to restore configuration snapshot from " + file, e);
+ // In case of parse error, issue a warning, ignore and continue
+ LOG.warn(
+ "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. ",
+ file, file);
+ LOG.warn(
+ "Note that subsequent config files may fail due to this problem. ",
+ "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
+ e);
+ }
+
+ return Optional.absent();
+ }
+
+ public static ConfigSnapshotHolder loadLastConfig(final File file) throws JAXBException {
+ JAXBContext jaxbContext = JAXBContext.newInstance(ConfigSnapshot.class);
+ Unmarshaller um = jaxbContext.createUnmarshaller();
+ XMLInputFactory xif = XMLInputFactory.newFactory();
+ xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
+ xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
+ try {
+ XMLStreamReader xsr = xif.createXMLStreamReader(new StreamSource(file));
+ return asHolder((ConfigSnapshot) um.unmarshal(xsr));
+ } catch (final XMLStreamException e) {
+ throw new JAXBException(e);