From 890ddb6fe10ba9cb7e570af4fe98ea85ed7babbe Mon Sep 17 00:00:00 2001 From: malakaganga Date: Thu, 21 Nov 2024 13:03:55 +0530 Subject: [PATCH] Fix Error while access large xml in PayloadFactory Initialize XMLInputFactory with XMLInputFactory.properties when instantiating PF to avoid skipping mandatory properties being added to factory. Fixes: https://github.com/wso2/product-micro-integrator/issues/3775 --- .../mediators/transform/PayloadFactoryMediator.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java index 8f4b00e2fa..ef87351660 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/transform/PayloadFactoryMediator.java @@ -84,6 +84,16 @@ public class PayloadFactoryMediator extends AbstractMediator { private static final Log log = LogFactory.getLog(PayloadFactoryMediator.class); public PayloadFactoryMediator() { + //ignore DTDs for XML Input + inputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); + inputFactory.setProperty(XMLInputFactory.IS_COALESCING, true); + Map props = StAXUtils.loadFactoryProperties("XMLInputFactory.properties"); + if (props != null) { + for (Object o : props.entrySet()) { + Map.Entry entry = (Map.Entry) o; + inputFactory.setProperty((String) entry.getKey(), entry.getValue()); + } + } } /**