aboutsummaryrefslogtreecommitdiffstats
path: root/cps-service
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2023-01-05 15:35:59 +0000
committermpriyank <priyank.maheshwari@est.tech>2023-01-05 15:36:04 +0000
commit850c4b8853029677d2161f529653b8c794339744 (patch)
tree1ae52457a5d0af125f95418066b22fbd40ed24f2 /cps-service
parentb48469262c83dc1e88b12d162de88a05ce61159c (diff)
Local DocumentBuilderFactory
- trying to use local DocumentBuilderFactory without any condition Issue-ID: CPS-1435 Change-Id: I209a31633427cbf6fdac3e465154a1b89b9ca89f Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
Diffstat (limited to 'cps-service')
-rw-r--r--cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java20
1 files changed, 5 insertions, 15 deletions
diff --git a/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java b/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java
index 10e1f50b54..10949e7c8f 100644
--- a/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java
+++ b/cps-service/src/main/java/org/onap/cps/utils/XmlFileUtils.java
@@ -49,9 +49,7 @@ import org.xml.sax.SAXException;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class XmlFileUtils {
- private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
private static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
- private static boolean isNewDocumentBuilderFactoryInstance = true;
private static boolean isNewTransformerFactoryInstance = true;
private static final Pattern XPATH_PROPERTY_REGEX =
Pattern.compile("\\[@(\\S{1,100})=['\\\"](\\S{1,100})['\\\"]\\]");
@@ -161,19 +159,11 @@ public class XmlFileUtils {
}
}
- private static DocumentBuilderFactory getDocumentBuilderFactory() throws ParserConfigurationException {
- if (isNewDocumentBuilderFactoryInstance) {
- documentBuilderFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
- documentBuilderFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
- documentBuilderFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
- documentBuilderFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
- documentBuilderFactory.setXIncludeAware(false);
- documentBuilderFactory.setExpandEntityReferences(false);
- documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
- documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
- documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
- isNewDocumentBuilderFactoryInstance = false;
- }
+ private static DocumentBuilderFactory getDocumentBuilderFactory() {
+
+ final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+ documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
return documentBuilderFactory;
}