- return asHolder((ConfigSnapshot) um.unmarshal(file));
- } catch (JAXBException e) {
- logger.warn("Unable to restore configuration snapshot from {}", file, e);
- throw new IllegalStateException("Unable to restore configuration snapshot from " + file, 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);