X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-persister-directory-xml-adapter%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fpersist%2Fstorage%2Fdirectory%2Fxml%2FXmlDirectoryPersister.java;h=7f8ebd7fddf8e7ee93a665106040ef4c83c5fb96;hb=721b580748cb93b3dac952ff1f111d0ab0da0c79;hp=ebba716e5a3d6f590025248eccae48b5b5247ac9;hpb=0e3f7da0306b3b723f87c79b82dfd2563a634e19;p=controller.git diff --git a/opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryPersister.java b/opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryPersister.java index ebba716e5a..7f8ebd7fdd 100644 --- a/opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryPersister.java +++ b/opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryPersister.java @@ -75,19 +75,30 @@ public class XmlDirectoryPersister implements Persister { List result = new ArrayList<>(); for (File file : sortedFiles) { logger.trace("Adding file '{}' to combined result", file); - ConfigSnapshotHolder h = fromXmlSnapshot(file); - result.add(h); + Optional h = fromXmlSnapshot(file); + // Ignore non valid snapshot + if(h.isPresent() == false) { + continue; + } + + result.add(h.get()); } return result; } - private ConfigSnapshotHolder fromXmlSnapshot(File file) { + private Optional fromXmlSnapshot(File file) { try { - return loadLastConfig(file); + return Optional.of(loadLastConfig(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); + // In case of parse error, issue a warning, ignore and continue + logger.warn( + "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. " + + "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.", + file, file, e); } + + return Optional.absent(); } public static ConfigSnapshotHolder loadLastConfig(File file) throws JAXBException {