summaryrefslogtreecommitdiffstats
path: root/cps-service
diff options
context:
space:
mode:
authormpriyank <priyank.maheshwari@est.tech>2023-01-09 09:58:28 +0000
committermpriyank <priyank.maheshwari@est.tech>2023-01-09 09:58:33 +0000
commit86cda427e084b45c0f76d67f0eeebe74ee419ff2 (patch)
tree97e8879371dc4f750790afc53b45882a23195331 /cps-service
parent377a02ce32ede76c52f6de709707cfd17daece6f (diff)
DocBuilderFactory one instance
- setting the property for DocumentBuilderFactory only once. Issue-ID: CPS-1435 Change-Id: Ib1509e86c2f5572d184945dc55f1818a7147c259 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.java10
1 files changed, 7 insertions, 3 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 a0d770191e..09f2e16c6a 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,6 +49,8 @@ import org.xml.sax.SAXException;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class XmlFileUtils {
+ private static final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ private static boolean isNewDocumentBuilderFactoryInstance = true;
private static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
private static boolean isNewTransformerFactoryInstance = true;
private static final Pattern XPATH_PROPERTY_REGEX =
@@ -161,9 +163,11 @@ public class XmlFileUtils {
private static DocumentBuilderFactory getDocumentBuilderFactory() {
- final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
- documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+ if (isNewDocumentBuilderFactoryInstance) {
+ documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
+ documentBuilderFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
+ isNewDocumentBuilderFactoryInstance = false;
+ }
return documentBuilderFactory;
}