This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new f46f5af03256 CAMEL-24216: Set xpathTotalOpLimit per TransformerFactory
instead of JVM-global system property
f46f5af03256 is described below
commit f46f5af032566eba6b4604d0d9c222301066db9c
Author: Guillaume Nodet <[email protected]>
AuthorDate: Tue Jul 28 18:38:18 2026 +0200
CAMEL-24216: Set xpathTotalOpLimit per TransformerFactory instead of
JVM-global system property
Co-authored-by: Claude Opus 4.6 <[email protected]>
Instead of manipulating the JVM-global jdk.xml.xpathTotalOpLimit system
property (which leaks across endpoints, fails on concurrent use, and
cannot be safely restored on startup failure), set the limit directly on
each TransformerFactory instance via factory.setAttribute().
The xpathTotalOpLimit option is now available both at component level
(default for all endpoints) and at endpoint level (per-endpoint override
via URI parameter). This is safe for concurrent use and does not affect
other components or JVMs.
For Saxon (xslt-saxon), the attribute is set with a try-catch since
Saxon's TransformerFactory may not support this JDK-specific attribute.
Co-authored-by: Claude Opus 4.6 <[email protected]>
---
.../org/apache/camel/catalog/components/xj.json | 5 +-
.../camel/catalog/components/xslt-saxon.json | 5 +-
.../org/apache/camel/catalog/components/xslt.json | 5 +-
.../camel/component/xj/XJEndpointUriFactory.java | 3 +-
.../META-INF/org/apache/camel/component/xj/xj.json | 5 +-
.../xslt/saxon/XsltSaxonEndpointUriFactory.java | 3 +-
.../camel/component/xslt/saxon/xslt-saxon.json | 5 +-
.../component/xslt/saxon/XsltSaxonEndpoint.java | 11 ++
.../component/xslt/XsltEndpointConfigurer.java | 6 +
.../component/xslt/XsltEndpointUriFactory.java | 3 +-
.../org/apache/camel/component/xslt/xslt.json | 5 +-
.../apache/camel/component/xslt/XsltComponent.java | 21 +---
.../apache/camel/component/xslt/XsltEndpoint.java | 32 ++++++
.../camel/component/xslt/XsltTotalOpsTest.java | 127 +++++++++++++++++++++
.../camel/component/xslt/ZXsltTotalOpsTest.java | 68 -----------
.../component/dsl/XjComponentBuilderFactory.java | 4 +-
.../component/dsl/XsltComponentBuilderFactory.java | 4 +-
.../dsl/XsltSaxonComponentBuilderFactory.java | 4 +-
.../endpoint/dsl/XJEndpointBuilderFactory.java | 34 ++++++
.../endpoint/dsl/XsltEndpointBuilderFactory.java | 34 ++++++
.../dsl/XsltSaxonEndpointBuilderFactory.java | 34 ++++++
21 files changed, 309 insertions(+), 109 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json
index 92da1189cdde..c2b6304df53e 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xj.json
@@ -36,7 +36,7 @@
"transformerFactoryConfigurationStrategy": { "index": 9, "kind":
"property", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 10, "kind": "property", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver. Should not be used together with the option 'uriResolverFactory'."
},
"uriResolverFactory": { "index": 11, "kind": "property", "displayName":
"Uri Resolver Factory", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltUriResolverFactory", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver which depends on a dynamic endpoint resource URI. Should not be
used together with the option 'uriResolver'." },
- "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. Configuring this corresponds to setting JVM system property:
jdk.xml.xpathTotalOpLimit" }
+ "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by each endpoint,
not as a JVM-global system [...]
},
"headers": {
"CamelXsltFileName": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The XSLT file name", "constantName":
"org.apache.camel.component.xj.XJConstants#XSLT_FILE_NAME" },
@@ -66,6 +66,7 @@
"transformerFactoryClass": { "index": 19, "kind": "parameter",
"displayName": "Transformer Factory Class", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "To use a custom XSLT transformer factory, specified as a FQN
class name" },
"transformerFactoryConfigurationStrategy": { "index": 20, "kind":
"parameter", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 21, "kind": "parameter", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
javax.xml.transform.URIResolver" },
- "xsltMessageLogger": { "index": 22, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
+ "xpathTotalOpLimit": { "index": 22, "kind": "parameter", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by this endpoint."
},
+ "xsltMessageLogger": { "index": 23, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt-saxon.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt-saxon.json
index 06db7161a9c7..d417ef14498e 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt-saxon.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt-saxon.json
@@ -36,7 +36,7 @@
"transformerFactoryConfigurationStrategy": { "index": 9, "kind":
"property", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 10, "kind": "property", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver. Should not be used together with the option 'uriResolverFactory'."
},
"uriResolverFactory": { "index": 11, "kind": "property", "displayName":
"Uri Resolver Factory", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltUriResolverFactory", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver which depends on a dynamic endpoint resource URI. Should not be
used together with the option 'uriResolver'." },
- "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. Configuring this corresponds to setting JVM system property:
jdk.xml.xpathTotalOpLimit" }
+ "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by each endpoint,
not as a JVM-global system [...]
},
"headers": {
"CamelXsltResourceUri": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "A URI for the template resource to load and use instead
of the endpoint configured.", "constantName":
"org.apache.camel.component.xslt.XsltConstants#XSLT_RESOURCE_URI" },
@@ -65,6 +65,7 @@
"transformerFactoryClass": { "index": 18, "kind": "parameter",
"displayName": "Transformer Factory Class", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "To use a custom XSLT transformer factory, specified as a FQN
class name" },
"transformerFactoryConfigurationStrategy": { "index": 19, "kind":
"parameter", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 20, "kind": "parameter", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
javax.xml.transform.URIResolver" },
- "xsltMessageLogger": { "index": 21, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
+ "xpathTotalOpLimit": { "index": 21, "kind": "parameter", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by this endpoint."
},
+ "xsltMessageLogger": { "index": 22, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt.json
index 31da13985769..a32e96e4d688 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/xslt.json
@@ -32,7 +32,7 @@
"transformerFactoryConfigurationStrategy": { "index": 5, "kind":
"property", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 6, "kind": "property", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver. Should not be used together with the option 'uriResolverFactory'."
},
"uriResolverFactory": { "index": 7, "kind": "property", "displayName":
"Uri Resolver Factory", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltUriResolverFactory", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver which depends on a dynamic endpoint resource URI. Should not be
used together with the option 'uriResolver'." },
- "xpathTotalOpLimit": { "index": 8, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. Configuring this corresponds to setting JVM system property:
jdk.xml.xpathTotalOpLimit" }
+ "xpathTotalOpLimit": { "index": 8, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by each endpoint,
not as a JVM-global system p [...]
},
"headers": {
"CamelXsltResourceUri": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "A URI for the template resource to load and use instead
of the endpoint configured.", "constantName":
"org.apache.camel.component.xslt.XsltConstants#XSLT_RESOURCE_URI" },
@@ -56,6 +56,7 @@
"transformerFactoryClass": { "index": 13, "kind": "parameter",
"displayName": "Transformer Factory Class", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "To use a custom XSLT transformer factory, specified as a FQN
class name" },
"transformerFactoryConfigurationStrategy": { "index": 14, "kind":
"parameter", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 15, "kind": "parameter", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
javax.xml.transform.URIResolver" },
- "xsltMessageLogger": { "index": 16, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
+ "xpathTotalOpLimit": { "index": 16, "kind": "parameter", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by this endpoint."
},
+ "xsltMessageLogger": { "index": 17, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
}
}
diff --git
a/components/camel-xj/src/generated/java/org/apache/camel/component/xj/XJEndpointUriFactory.java
b/components/camel-xj/src/generated/java/org/apache/camel/component/xj/XJEndpointUriFactory.java
index 6fbb27dedb02..450a0b259c34 100644
---
a/components/camel-xj/src/generated/java/org/apache/camel/component/xj/XJEndpointUriFactory.java
+++
b/components/camel-xj/src/generated/java/org/apache/camel/component/xj/XJEndpointUriFactory.java
@@ -24,7 +24,7 @@ public class XJEndpointUriFactory extends
org.apache.camel.support.component.End
private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
private static final Map<String, String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(23);
+ Set<String> props = new HashSet<>(24);
props.add("allowStAX");
props.add("allowTemplateFromHeader");
props.add("contentCache");
@@ -47,6 +47,7 @@ public class XJEndpointUriFactory extends
org.apache.camel.support.component.End
props.add("transformerFactoryConfigurationStrategy");
props.add("uriResolver");
props.add("useJsonBody");
+ props.add("xpathTotalOpLimit");
props.add("xsltMessageLogger");
PROPERTY_NAMES = Collections.unmodifiableSet(props);
SECRET_PROPERTY_NAMES = Collections.emptySet();
diff --git
a/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json
b/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json
index 92da1189cdde..c2b6304df53e 100644
---
a/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json
+++
b/components/camel-xj/src/generated/resources/META-INF/org/apache/camel/component/xj/xj.json
@@ -36,7 +36,7 @@
"transformerFactoryConfigurationStrategy": { "index": 9, "kind":
"property", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 10, "kind": "property", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver. Should not be used together with the option 'uriResolverFactory'."
},
"uriResolverFactory": { "index": 11, "kind": "property", "displayName":
"Uri Resolver Factory", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltUriResolverFactory", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver which depends on a dynamic endpoint resource URI. Should not be
used together with the option 'uriResolver'." },
- "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. Configuring this corresponds to setting JVM system property:
jdk.xml.xpathTotalOpLimit" }
+ "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by each endpoint,
not as a JVM-global system [...]
},
"headers": {
"CamelXsltFileName": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "The XSLT file name", "constantName":
"org.apache.camel.component.xj.XJConstants#XSLT_FILE_NAME" },
@@ -66,6 +66,7 @@
"transformerFactoryClass": { "index": 19, "kind": "parameter",
"displayName": "Transformer Factory Class", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "To use a custom XSLT transformer factory, specified as a FQN
class name" },
"transformerFactoryConfigurationStrategy": { "index": 20, "kind":
"parameter", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 21, "kind": "parameter", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
javax.xml.transform.URIResolver" },
- "xsltMessageLogger": { "index": 22, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
+ "xpathTotalOpLimit": { "index": 22, "kind": "parameter", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by this endpoint."
},
+ "xsltMessageLogger": { "index": 23, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
}
}
diff --git
a/components/camel-xslt-saxon/src/generated/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpointUriFactory.java
b/components/camel-xslt-saxon/src/generated/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpointUriFactory.java
index 8e1e036d9d02..a5e48a0a6b57 100644
---
a/components/camel-xslt-saxon/src/generated/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpointUriFactory.java
+++
b/components/camel-xslt-saxon/src/generated/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpointUriFactory.java
@@ -24,7 +24,7 @@ public class XsltSaxonEndpointUriFactory extends
org.apache.camel.support.compon
private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
private static final Map<String, String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(22);
+ Set<String> props = new HashSet<>(23);
props.add("allowStAX");
props.add("allowTemplateFromHeader");
props.add("contentCache");
@@ -46,6 +46,7 @@ public class XsltSaxonEndpointUriFactory extends
org.apache.camel.support.compon
props.add("transformerFactoryConfigurationStrategy");
props.add("uriResolver");
props.add("useJsonBody");
+ props.add("xpathTotalOpLimit");
props.add("xsltMessageLogger");
PROPERTY_NAMES = Collections.unmodifiableSet(props);
SECRET_PROPERTY_NAMES = Collections.emptySet();
diff --git
a/components/camel-xslt-saxon/src/generated/resources/META-INF/org/apache/camel/component/xslt/saxon/xslt-saxon.json
b/components/camel-xslt-saxon/src/generated/resources/META-INF/org/apache/camel/component/xslt/saxon/xslt-saxon.json
index 06db7161a9c7..d417ef14498e 100644
---
a/components/camel-xslt-saxon/src/generated/resources/META-INF/org/apache/camel/component/xslt/saxon/xslt-saxon.json
+++
b/components/camel-xslt-saxon/src/generated/resources/META-INF/org/apache/camel/component/xslt/saxon/xslt-saxon.json
@@ -36,7 +36,7 @@
"transformerFactoryConfigurationStrategy": { "index": 9, "kind":
"property", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 10, "kind": "property", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver. Should not be used together with the option 'uriResolverFactory'."
},
"uriResolverFactory": { "index": 11, "kind": "property", "displayName":
"Uri Resolver Factory", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltUriResolverFactory", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver which depends on a dynamic endpoint resource URI. Should not be
used together with the option 'uriResolver'." },
- "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. Configuring this corresponds to setting JVM system property:
jdk.xml.xpathTotalOpLimit" }
+ "xpathTotalOpLimit": { "index": 12, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by each endpoint,
not as a JVM-global system [...]
},
"headers": {
"CamelXsltResourceUri": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "A URI for the template resource to load and use instead
of the endpoint configured.", "constantName":
"org.apache.camel.component.xslt.XsltConstants#XSLT_RESOURCE_URI" },
@@ -65,6 +65,7 @@
"transformerFactoryClass": { "index": 18, "kind": "parameter",
"displayName": "Transformer Factory Class", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "To use a custom XSLT transformer factory, specified as a FQN
class name" },
"transformerFactoryConfigurationStrategy": { "index": 19, "kind":
"parameter", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 20, "kind": "parameter", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
javax.xml.transform.URIResolver" },
- "xsltMessageLogger": { "index": 21, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
+ "xpathTotalOpLimit": { "index": 21, "kind": "parameter", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by this endpoint."
},
+ "xsltMessageLogger": { "index": 22, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
}
}
diff --git
a/components/camel-xslt-saxon/src/main/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpoint.java
b/components/camel-xslt-saxon/src/main/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpoint.java
index 9f118760d367..062e463f2f8d 100644
---
a/components/camel-xslt-saxon/src/main/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpoint.java
+++
b/components/camel-xslt-saxon/src/main/java/org/apache/camel/component/xslt/saxon/XsltSaxonEndpoint.java
@@ -231,6 +231,17 @@ public class XsltSaxonEndpoint extends XsltEndpoint {
if (strategy != null) {
strategy.configure(factory, this);
}
+
+ int effectiveXpathTotalOpLimit = getXpathTotalOpLimit() > 0
+ ? getXpathTotalOpLimit()
+ : ((XsltSaxonComponent)
getComponent()).getXpathTotalOpLimit();
+ if (effectiveXpathTotalOpLimit > 0) {
+ try {
+ factory.setAttribute("jdk.xml.xpathTotalOpLimit",
effectiveXpathTotalOpLimit);
+ } catch (IllegalArgumentException e) {
+ LOG.debug("TransformerFactory does not support
jdk.xml.xpathTotalOpLimit");
+ }
+ }
}
LOG.debug("Using TransformerFactory {}", factory);
diff --git
a/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointConfigurer.java
b/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointConfigurer.java
index 9756ef50edba..8f18367aac64 100644
---
a/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointConfigurer.java
+++
b/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointConfigurer.java
@@ -51,6 +51,8 @@ public class XsltEndpointConfigurer extends
PropertyConfigurerSupport implements
case "transformerFactoryConfigurationStrategy":
target.setTransformerFactoryConfigurationStrategy(property(camelContext,
org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy.class,
value)); return true;
case "uriresolver":
case "uriResolver": target.setUriResolver(property(camelContext,
javax.xml.transform.URIResolver.class, value)); return true;
+ case "xpathtotaloplimit":
+ case "xpathTotalOpLimit":
target.setXpathTotalOpLimit(property(camelContext, int.class, value)); return
true;
case "xsltmessagelogger":
case "xsltMessageLogger":
target.setXsltMessageLogger(property(camelContext,
org.apache.camel.component.xslt.XsltMessageLogger.class, value)); return true;
default: return false;
@@ -88,6 +90,8 @@ public class XsltEndpointConfigurer extends
PropertyConfigurerSupport implements
case "transformerFactoryConfigurationStrategy": return
org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy.class;
case "uriresolver":
case "uriResolver": return javax.xml.transform.URIResolver.class;
+ case "xpathtotaloplimit":
+ case "xpathTotalOpLimit": return int.class;
case "xsltmessagelogger":
case "xsltMessageLogger": return
org.apache.camel.component.xslt.XsltMessageLogger.class;
default: return null;
@@ -126,6 +130,8 @@ public class XsltEndpointConfigurer extends
PropertyConfigurerSupport implements
case "transformerFactoryConfigurationStrategy": return
target.getTransformerFactoryConfigurationStrategy();
case "uriresolver":
case "uriResolver": return target.getUriResolver();
+ case "xpathtotaloplimit":
+ case "xpathTotalOpLimit": return target.getXpathTotalOpLimit();
case "xsltmessagelogger":
case "xsltMessageLogger": return target.getXsltMessageLogger();
default: return null;
diff --git
a/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointUriFactory.java
b/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointUriFactory.java
index a9de8133f6b1..488e55532893 100644
---
a/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointUriFactory.java
+++
b/components/camel-xslt/src/generated/java/org/apache/camel/component/xslt/XsltEndpointUriFactory.java
@@ -24,7 +24,7 @@ public class XsltEndpointUriFactory extends
org.apache.camel.support.component.E
private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
private static final Map<String, String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(17);
+ Set<String> props = new HashSet<>(18);
props.add("allowTemplateFromHeader");
props.add("contentCache");
props.add("deleteOutputFile");
@@ -41,6 +41,7 @@ public class XsltEndpointUriFactory extends
org.apache.camel.support.component.E
props.add("transformerFactoryClass");
props.add("transformerFactoryConfigurationStrategy");
props.add("uriResolver");
+ props.add("xpathTotalOpLimit");
props.add("xsltMessageLogger");
PROPERTY_NAMES = Collections.unmodifiableSet(props);
SECRET_PROPERTY_NAMES = Collections.emptySet();
diff --git
a/components/camel-xslt/src/generated/resources/META-INF/org/apache/camel/component/xslt/xslt.json
b/components/camel-xslt/src/generated/resources/META-INF/org/apache/camel/component/xslt/xslt.json
index 31da13985769..a32e96e4d688 100644
---
a/components/camel-xslt/src/generated/resources/META-INF/org/apache/camel/component/xslt/xslt.json
+++
b/components/camel-xslt/src/generated/resources/META-INF/org/apache/camel/component/xslt/xslt.json
@@ -32,7 +32,7 @@
"transformerFactoryConfigurationStrategy": { "index": 5, "kind":
"property", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 6, "kind": "property", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver. Should not be used together with the option 'uriResolverFactory'."
},
"uriResolverFactory": { "index": 7, "kind": "property", "displayName":
"Uri Resolver Factory", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltUriResolverFactory", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
UriResolver which depends on a dynamic endpoint resource URI. Should not be
used together with the option 'uriResolver'." },
- "xpathTotalOpLimit": { "index": 8, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. Configuring this corresponds to setting JVM system property:
jdk.xml.xpathTotalOpLimit" }
+ "xpathTotalOpLimit": { "index": 8, "kind": "property", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by each endpoint,
not as a JVM-global system p [...]
},
"headers": {
"CamelXsltResourceUri": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "", "required": false, "javaType": "String",
"deprecated": false, "deprecationNote": "", "autowired": false, "secret":
false, "description": "A URI for the template resource to load and use instead
of the endpoint configured.", "constantName":
"org.apache.camel.component.xslt.XsltConstants#XSLT_RESOURCE_URI" },
@@ -56,6 +56,7 @@
"transformerFactoryClass": { "index": 13, "kind": "parameter",
"displayName": "Transformer Factory Class", "group": "advanced", "label":
"advanced", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "autowired": false, "secret": false,
"description": "To use a custom XSLT transformer factory, specified as a FQN
class name" },
"transformerFactoryConfigurationStrategy": { "index": 14, "kind":
"parameter", "displayName": "Transformer Factory Configuration Strategy",
"group": "advanced", "label": "advanced", "required": false, "type": "object",
"javaType":
"org.apache.camel.component.xslt.TransformerFactoryConfigurationStrategy",
"deprecated": false, "autowired": false, "secret": false, "description": "A
configuration strategy to apply on freshly created instances of
TransformerFactory." },
"uriResolver": { "index": 15, "kind": "parameter", "displayName": "Uri
Resolver", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "javax.xml.transform.URIResolver", "deprecated": false,
"autowired": false, "secret": false, "description": "To use a custom
javax.xml.transform.URIResolver" },
- "xsltMessageLogger": { "index": 16, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
+ "xpathTotalOpLimit": { "index": 16, "kind": "parameter", "displayName":
"Xpath Total Op Limit", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 10000, "description": "Limits the total
number of XPath operators in an XSL Stylesheet. The default (from JDK) is
10000. The limit is set per TransformerFactory instance used by this endpoint."
},
+ "xsltMessageLogger": { "index": 17, "kind": "parameter", "displayName":
"Xslt Message Logger", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType":
"org.apache.camel.component.xslt.XsltMessageLogger", "deprecated": false,
"autowired": false, "secret": false, "description": "A consumer to messages
generated during XSLT transformations." }
}
}
diff --git
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
index 07eb42709281..1ba15f2d8607 100644
---
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
+++
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
@@ -36,8 +36,6 @@ public class XsltComponent extends DefaultComponent {
private static final Logger LOG =
LoggerFactory.getLogger(XsltComponent.class);
- private static final String XPATH_TOTAL_OP_LIMIT =
"jdk.xml.xpathTotalOpLimit";
-
@Metadata(label = "advanced")
private URIResolver uriResolver;
@Metadata(label = "advanced")
@@ -136,29 +134,12 @@ public class XsltComponent extends DefaultComponent {
/**
* Limits the total number of XPath operators in an XSL Stylesheet. The
default (from JDK) is 10000.
*
- * Configuring this corresponds to setting JVM system property:
jdk.xml.xpathTotalOpLimit
+ * The limit is set per TransformerFactory instance used by each endpoint,
not as a JVM-global system property.
*/
public void setXpathTotalOpLimit(int xpathTotalOpLimit) {
this.xpathTotalOpLimit = xpathTotalOpLimit;
}
- @Override
- protected void doInit() throws Exception {
- super.doInit();
- if (xpathTotalOpLimit > 0) {
- LOG.info("XsltComponent is setting JVM system property:
jdk.xml.xpathTotalOpLimit=" + xpathTotalOpLimit);
- System.setProperty(XPATH_TOTAL_OP_LIMIT, "" + xpathTotalOpLimit);
- }
- }
-
- @Override
- protected void doShutdown() throws Exception {
- super.doShutdown();
- if (xpathTotalOpLimit > 0) {
- System.clearProperty(XPATH_TOTAL_OP_LIMIT);
- }
- }
-
@Override
protected Endpoint createEndpoint(String uri, final String remaining,
Map<String, Object> parameters) throws Exception {
XsltEndpoint endpoint = createXsltEndpoint(uri);
diff --git
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
index d074b26085a2..bd7e0c090450 100644
---
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
+++
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
@@ -48,6 +48,7 @@ import org.apache.camel.spi.UriPath;
import org.apache.camel.support.ProcessorEndpoint;
import org.apache.camel.support.ResourceHelper;
import org.apache.camel.support.builder.ExpressionBuilder;
+import org.apache.camel.support.builder.xml.XMLConverterHelper;
import org.apache.camel.support.service.ServiceHelper;
import org.apache.camel.util.ObjectHelper;
import org.slf4j.Logger;
@@ -101,6 +102,8 @@ public class XsltEndpoint extends ProcessorEndpoint {
private XsltMessageLogger xsltMessageLogger;
@UriParam
private String source;
+ @UriParam(label = "advanced", defaultValue = "10000")
+ private int xpathTotalOpLimit;
public XsltEndpoint(String endpointUri, Component component) {
super(endpointUri, component);
@@ -454,6 +457,17 @@ public class XsltEndpoint extends ProcessorEndpoint {
}
}
+ // resolve the effective xpathTotalOpLimit: endpoint value takes
precedence, then component value
+ int effectiveXpathTotalOpLimit = xpathTotalOpLimit > 0
+ ? xpathTotalOpLimit
+ : ((XsltComponent) getComponent()).getXpathTotalOpLimit();
+
+ // if xpathTotalOpLimit is configured but no factory was explicitly
set, create a default one
+ // so we can set the limit per-factory instance instead of using a
JVM-global system property
+ if (factory == null && effectiveXpathTotalOpLimit > 0) {
+ factory = new XMLConverterHelper().createTransformerFactory();
+ }
+
if (factory != null) {
final TransformerFactoryConfigurationStrategy tfConfigStrategy =
transformerFactoryConfigurationStrategy != null
? transformerFactoryConfigurationStrategy
@@ -462,6 +476,11 @@ public class XsltEndpoint extends ProcessorEndpoint {
tfConfigStrategy.configure(factory, this);
}
+ if (effectiveXpathTotalOpLimit > 0) {
+ LOG.debug("Setting jdk.xml.xpathTotalOpLimit={} on
TransformerFactory", effectiveXpathTotalOpLimit);
+ factory.setAttribute("jdk.xml.xpathTotalOpLimit",
effectiveXpathTotalOpLimit);
+ }
+
LOG.debug("Using TransformerFactory {}", factory);
xslt.setTransformerFactory(factory);
}
@@ -526,6 +545,19 @@ public class XsltEndpoint extends ProcessorEndpoint {
this.source = source;
}
+ public int getXpathTotalOpLimit() {
+ return xpathTotalOpLimit;
+ }
+
+ /**
+ * Limits the total number of XPath operators in an XSL Stylesheet. The
default (from JDK) is 10000.
+ *
+ * The limit is set per TransformerFactory instance used by this endpoint.
+ */
+ public void setXpathTotalOpLimit(int xpathTotalOpLimit) {
+ this.xpathTotalOpLimit = xpathTotalOpLimit;
+ }
+
@Override
protected void doStop() throws Exception {
super.doStop();
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltTotalOpsTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltTotalOpsTest.java
new file mode 100644
index 000000000000..1cd4de60e80f
--- /dev/null
+++
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/XsltTotalOpsTest.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xslt;
+
+import javax.xml.transform.TransformerConfigurationException;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+class XsltTotalOpsTest extends ContextTestSupport {
+
+ @Override
+ public boolean isUseRouteBuilder() {
+ return false;
+ }
+
+ @Test
+ void testXsltTotalOpsLimitRejectsStylesheet() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ XsltComponent xslt = context.getComponent("xslt",
XsltComponent.class);
+ xslt.setXpathTotalOpLimit(1);
+
+ from("direct:start")
+
.to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes").to("mock:result");
+ }
+ });
+
+ Exception e = assertThrows(Exception.class, () -> context.start(),
+ "Should fail due to low total ops");
+
+ TransformerConfigurationException tce
+ = assertIsInstanceOf(TransformerConfigurationException.class,
e.getCause().getCause().getCause());
+ assertThat(tce.getMessage()).contains("exceeds the '1' limit");
+ }
+
+ @Test
+ void testXsltTotalOpsLimitDoesNotLeakSystemProperty() throws Exception {
+ // Ensure no pre-existing system property
+ System.clearProperty("jdk.xml.xpathTotalOpLimit");
+
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ XsltComponent xslt = context.getComponent("xslt",
XsltComponent.class);
+ xslt.setXpathTotalOpLimit(1);
+
+ from("direct:start")
+
.to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes").to("mock:result");
+ }
+ });
+
+ // Context start will fail due to low limit, but the point is to check
+ // that no system property was set
+ assertThrows(Exception.class, () -> context.start());
+
+ // The limit should be set per-factory, not as a system property
(CAMEL-24216)
+ assertThat(System.getProperty("jdk.xml.xpathTotalOpLimit"))
+ .as("xpathTotalOpLimit should not leak as a JVM system
property")
+ .isNull();
+ }
+
+ @Test
+ void testXsltTotalOpLimitHighEnoughAllowsStylesheet() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ XsltComponent xslt = context.getComponent("xslt",
XsltComponent.class);
+ xslt.setXpathTotalOpLimit(20000);
+
+ from("direct:start")
+
.to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes").to("mock:result");
+ }
+ });
+
+ // Should start successfully with a high enough limit
+ context.start();
+
+ // No system property should be leaked
+ assertThat(System.getProperty("jdk.xml.xpathTotalOpLimit"))
+ .as("xpathTotalOpLimit should not leak as a JVM system
property")
+ .isNull();
+
+ context.stop();
+ }
+
+ @Test
+ void testXsltTotalOpLimitPerEndpointUri() throws Exception {
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from("direct:start")
+
.to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes&xpathTotalOpLimit=20000")
+ .to("mock:result");
+ }
+ });
+
+ // Should start successfully with the limit set via endpoint URI
+ context.start();
+
+ // No system property should be leaked
+ assertThat(System.getProperty("jdk.xml.xpathTotalOpLimit"))
+ .as("xpathTotalOpLimit should not leak as a JVM system
property")
+ .isNull();
+
+ context.stop();
+ }
+}
diff --git
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/ZXsltTotalOpsTest.java
b/core/camel-core/src/test/java/org/apache/camel/component/xslt/ZXsltTotalOpsTest.java
deleted file mode 100644
index bed96c1b65ce..000000000000
---
a/core/camel-core/src/test/java/org/apache/camel/component/xslt/ZXsltTotalOpsTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.xslt;
-
-import javax.xml.transform.TransformerConfigurationException;
-
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.builder.RouteBuilder;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.parallel.Isolated;
-import org.junit.jupiter.api.parallel.ResourceLock;
-import org.junit.jupiter.api.parallel.Resources;
-
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-@Isolated
-@ResourceLock(Resources.SYSTEM_PROPERTIES)
-public class ZXsltTotalOpsTest extends ContextTestSupport {
-
- @Override
- public boolean isUseRouteBuilder() {
- return false;
- }
-
- @AfterEach
- void clearXpathLimit() {
- // Workaround to https://issues.apache.org/jira/browse/CAMEL-24216
- System.clearProperty("jdk.xml.xpathTotalOpLimit");
- }
-
- @Test
- public void testXsltTotalOps() throws Exception {
- context.addRoutes(new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- XsltComponent xslt = context.getComponent("xslt",
XsltComponent.class);
- xslt.setXpathTotalOpLimit(1);
-
- from("direct:start")
-
.to("xslt:org/apache/camel/component/xslt/example.xsl?output=bytes").to("mock:result");
- }
- });
-
- Exception e = assertThrows(Exception.class, () -> context.start(),
- "Should fail due to low total ops");
-
- TransformerConfigurationException tce
- = assertIsInstanceOf(TransformerConfigurationException.class,
e.getCause().getCause().getCause());
- assertTrue(tce.getMessage().endsWith("operators that exceeds the '1'
limit set by 'system property'."));
- }
-
-}
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XjComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XjComponentBuilderFactory.java
index 9291ba0ff2bf..ae52c2fa98d1 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XjComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XjComponentBuilderFactory.java
@@ -281,8 +281,8 @@ public interface XjComponentBuilderFactory {
/**
* Limits the total number of XPath operators in an XSL Stylesheet. The
- * default (from JDK) is 10000. Configuring this corresponds to setting
- * JVM system property: jdk.xml.xpathTotalOpLimit.
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by each endpoint, not as a JVM-global system property.
*
* The option is a: <code>int</code> type.
*
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltComponentBuilderFactory.java
index 6390d5d75578..136640d8871d 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltComponentBuilderFactory.java
@@ -210,8 +210,8 @@ public interface XsltComponentBuilderFactory {
/**
* Limits the total number of XPath operators in an XSL Stylesheet. The
- * default (from JDK) is 10000. Configuring this corresponds to setting
- * JVM system property: jdk.xml.xpathTotalOpLimit.
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by each endpoint, not as a JVM-global system property.
*
* The option is a: <code>int</code> type.
*
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltSaxonComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltSaxonComponentBuilderFactory.java
index 9ae7c4cb9298..ec7c13e405c5 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltSaxonComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/XsltSaxonComponentBuilderFactory.java
@@ -281,8 +281,8 @@ public interface XsltSaxonComponentBuilderFactory {
/**
* Limits the total number of XPath operators in an XSL Stylesheet. The
- * default (from JDK) is 10000. Configuring this corresponds to setting
- * JVM system property: jdk.xml.xpathTotalOpLimit.
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by each endpoint, not as a JVM-global system property.
*
* The option is a: <code>int</code> type.
*
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XJEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XJEndpointBuilderFactory.java
index 6c33b15a0544..fcbbd82a6ace 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XJEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XJEndpointBuilderFactory.java
@@ -735,6 +735,40 @@ public interface XJEndpointBuilderFactory {
doSetProperty("uriResolver", uriResolver);
return this;
}
+ /**
+ * Limits the total number of XPath operators in an XSL Stylesheet. The
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by this endpoint.
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Default: 10000
+ * Group: advanced
+ *
+ * @param xpathTotalOpLimit the value to set
+ * @return the dsl builder
+ */
+ default AdvancedXJEndpointBuilder xpathTotalOpLimit(int
xpathTotalOpLimit) {
+ doSetProperty("xpathTotalOpLimit", xpathTotalOpLimit);
+ return this;
+ }
+ /**
+ * Limits the total number of XPath operators in an XSL Stylesheet. The
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by this endpoint.
+ *
+ * The option will be converted to a <code>int</code> type.
+ *
+ * Default: 10000
+ * Group: advanced
+ *
+ * @param xpathTotalOpLimit the value to set
+ * @return the dsl builder
+ */
+ default AdvancedXJEndpointBuilder xpathTotalOpLimit(String
xpathTotalOpLimit) {
+ doSetProperty("xpathTotalOpLimit", xpathTotalOpLimit);
+ return this;
+ }
/**
* A consumer to messages generated during XSLT transformations.
*
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltEndpointBuilderFactory.java
index 0629b38ea7ba..765685d487da 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltEndpointBuilderFactory.java
@@ -547,6 +547,40 @@ public interface XsltEndpointBuilderFactory {
doSetProperty("uriResolver", uriResolver);
return this;
}
+ /**
+ * Limits the total number of XPath operators in an XSL Stylesheet. The
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by this endpoint.
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Default: 10000
+ * Group: advanced
+ *
+ * @param xpathTotalOpLimit the value to set
+ * @return the dsl builder
+ */
+ default AdvancedXsltEndpointBuilder xpathTotalOpLimit(int
xpathTotalOpLimit) {
+ doSetProperty("xpathTotalOpLimit", xpathTotalOpLimit);
+ return this;
+ }
+ /**
+ * Limits the total number of XPath operators in an XSL Stylesheet. The
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by this endpoint.
+ *
+ * The option will be converted to a <code>int</code> type.
+ *
+ * Default: 10000
+ * Group: advanced
+ *
+ * @param xpathTotalOpLimit the value to set
+ * @return the dsl builder
+ */
+ default AdvancedXsltEndpointBuilder xpathTotalOpLimit(String
xpathTotalOpLimit) {
+ doSetProperty("xpathTotalOpLimit", xpathTotalOpLimit);
+ return this;
+ }
/**
* A consumer to messages generated during XSLT transformations.
*
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltSaxonEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltSaxonEndpointBuilderFactory.java
index 96dad52ea0d5..08d781ccb3ab 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltSaxonEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/XsltSaxonEndpointBuilderFactory.java
@@ -703,6 +703,40 @@ public interface XsltSaxonEndpointBuilderFactory {
doSetProperty("uriResolver", uriResolver);
return this;
}
+ /**
+ * Limits the total number of XPath operators in an XSL Stylesheet. The
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by this endpoint.
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Default: 10000
+ * Group: advanced
+ *
+ * @param xpathTotalOpLimit the value to set
+ * @return the dsl builder
+ */
+ default AdvancedXsltSaxonEndpointBuilder xpathTotalOpLimit(int
xpathTotalOpLimit) {
+ doSetProperty("xpathTotalOpLimit", xpathTotalOpLimit);
+ return this;
+ }
+ /**
+ * Limits the total number of XPath operators in an XSL Stylesheet. The
+ * default (from JDK) is 10000. The limit is set per TransformerFactory
+ * instance used by this endpoint.
+ *
+ * The option will be converted to a <code>int</code> type.
+ *
+ * Default: 10000
+ * Group: advanced
+ *
+ * @param xpathTotalOpLimit the value to set
+ * @return the dsl builder
+ */
+ default AdvancedXsltSaxonEndpointBuilder xpathTotalOpLimit(String
xpathTotalOpLimit) {
+ doSetProperty("xpathTotalOpLimit", xpathTotalOpLimit);
+ return this;
+ }
/**
* A consumer to messages generated during XSLT transformations.
*