X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=common%2Futil%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Futil%2Fxml%2FUntrustedXML.java;h=8619875c2a67728e9c4d42f48dc5f8295abb391e;hb=6bb7f3a20168a59eeeea366d7d30fa29702e522f;hp=05ef089bdb7ede0a1a577f77f67e13b04b54551b;hpb=ac6b1c788424ca50221ce7b243e4255a8b6fe4c4;p=yangtools.git diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/xml/UntrustedXML.java b/common/util/src/main/java/org/opendaylight/yangtools/util/xml/UntrustedXML.java index 05ef089bdb..8619875c2a 100644 --- a/common/util/src/main/java/org/opendaylight/yangtools/util/xml/UntrustedXML.java +++ b/common/util/src/main/java/org/opendaylight/yangtools/util/xml/UntrustedXML.java @@ -22,6 +22,8 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; /** * Set of utility methods for instantiating parser that deal with untrusted XML sources. @@ -31,6 +33,7 @@ import org.xml.sax.SAXException; @Beta public final class UntrustedXML { private static final DocumentBuilderFactory DBF; + static { final DocumentBuilderFactory f = DocumentBuilderFactory.newInstance(); f.setCoalescing(true); @@ -52,6 +55,7 @@ public final class UntrustedXML { } private static final SAXParserFactory SPF; + static { final SAXParserFactory f = SAXParserFactory.newInstance(); f.setNamespaceAware(true); @@ -62,7 +66,7 @@ public final class UntrustedXML { f.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); f.setFeature("http://xml.org/sax/features/external-general-entities", false); f.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - } catch (final Exception e) { + } catch (final SAXNotRecognizedException | SAXNotSupportedException | ParserConfigurationException e) { throw new ExceptionInInitializerError(e); } @@ -70,6 +74,7 @@ public final class UntrustedXML { } private static final XMLInputFactory XIF; + static { final XMLInputFactory f = XMLInputFactory.newInstance();