X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fblueprint%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fblueprint%2Fext%2FDataStoreAppConfigDefaultXMLReader.java;h=4dea3404f9f073677541678671786e7627f9293b;hb=HEAD;hp=c1474929551c25e64f4998f926ee0b4e0407b29d;hpb=abaef4a5ae37f27542155457fe7306a4662b1eeb;p=controller.git diff --git a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigDefaultXMLReader.java b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigDefaultXMLReader.java index c147492955..4dea3404f9 100644 --- a/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigDefaultXMLReader.java +++ b/opendaylight/blueprint/src/main/java/org/opendaylight/controller/blueprint/ext/DataStoreAppConfigDefaultXMLReader.java @@ -14,7 +14,6 @@ import java.io.InputStream; import java.net.URISyntaxException; import java.net.URL; import java.util.Optional; -import javax.xml.parsers.ParserConfigurationException; import javax.xml.stream.XMLStreamException; import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer; import org.opendaylight.mdsal.dom.api.DOMSchemaService; @@ -54,7 +53,7 @@ public class DataStoreAppConfigDefaultXMLReader { @FunctionalInterface public interface FallbackConfigProvider { NormalizedNode get(SchemaTreeInference dataSchema) - throws IOException, XMLStreamException, ParserConfigurationException, SAXException, URISyntaxException; + throws IOException, XMLStreamException, SAXException, URISyntaxException; } @FunctionalInterface @@ -93,8 +92,8 @@ public class DataStoreAppConfigDefaultXMLReader { return Resources.getResource(testClass, defaultAppConfigFileName); } - public T createDefaultInstance() throws ConfigXMLReaderException, ParserConfigurationException, XMLStreamException, - IOException, SAXException, URISyntaxException { + public T createDefaultInstance() throws ConfigXMLReaderException, XMLStreamException, IOException, SAXException, + URISyntaxException { return createDefaultInstance(dataSchema -> { throw new IllegalArgumentException( "Failed to read XML (not creating model from defaults as runtime would, for better clarity in tests)"); @@ -103,7 +102,7 @@ public class DataStoreAppConfigDefaultXMLReader { @SuppressWarnings("unchecked") public T createDefaultInstance(final FallbackConfigProvider fallback) throws ConfigXMLReaderException, - URISyntaxException, ParserConfigurationException, XMLStreamException, SAXException, IOException { + URISyntaxException, XMLStreamException, SAXException, IOException { YangInstanceIdentifier yangPath = bindingSerializer.toYangInstanceIdentifier(bindingContext.appConfigPath); LOG.debug("{}: Creating app config instance from path {}, Qname: {}", logName, yangPath, @@ -176,7 +175,7 @@ public class DataStoreAppConfigDefaultXMLReader { if (!optionalURL.isPresent()) { return null; } - URL url = optionalURL.get(); + URL url = optionalURL.orElseThrow(); try (InputStream is = url.openStream()) { Document root = UntrustedXML.newDocumentBuilder().parse(is); NormalizedNode dataNode = bindingContext.parseDataElement(root.getDocumentElement(), @@ -185,8 +184,7 @@ public class DataStoreAppConfigDefaultXMLReader { LOG.debug("{}: Parsed data node: {}", logName, dataNode); return dataNode; - } catch (final IOException | SAXException | XMLStreamException | ParserConfigurationException - | URISyntaxException e) { + } catch (final IOException | SAXException | XMLStreamException | URISyntaxException e) { String msg = String.format("%s: Could not read/parse app config %s", logName, url); LOG.error(msg, e); throw new ConfigXMLReaderException(msg, e);