Skip to content

Commit

Permalink
The saaj.use.default.transformer.factory system property to force usa…
Browse files Browse the repository at this point in the history
…ge of the TransformerFactory builtin system-default implementation
  • Loading branch information
Pavel Novichenko committed Feb 20, 2024
1 parent e2ebbef commit d8706c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.xml.transform.stream.StreamSource;

import com.sun.xml.messaging.saaj.util.LogDomainConstants;
import com.sun.xml.messaging.saaj.util.SAAJUtil;
import org.w3c.dom.Document;

import com.sun.xml.messaging.saaj.util.XMLDeclarationParser;
Expand Down Expand Up @@ -77,7 +78,8 @@ public class EfficientStreamingTransformer extends Transformer {

private EfficientStreamingTransformer() {
boolean log = LOG.compareAndSet(true, false);
TransformerFactory tf = TransformerFactory.newInstance();
boolean useDefaultTransformerFactory = SAAJUtil.getSystemBoolean("saaj.use.default.transformer.factory");
TransformerFactory tf = useDefaultTransformerFactory ? TransformerFactory.newDefaultInstance() : TransformerFactory.newInstance();
try {
tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
} catch (TransformerConfigurationException e) {
Expand Down
9 changes: 9 additions & 0 deletions saaj-ri/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,15 @@
* large attachments in incoming messages. The default is false.</td>
* </tr>
*
* <tr>
* <td><a id="saaj.use.default.transformer.factory">saaj.use.default.transformer.factory</a></td>
* <td>boolean</td>
* <td>The {@code saaj.use.default.transformer.factory} property forces usage of
* the {@code TransformerFactory} builtin system-default implementation instead of the
* <a href="https://docs.oracle.com/en/java/javase/21/docs/api/java.xml/module-summary.html#LookupMechanism">JAXP Lookup Mechanism</a>.
* The default is false.</td>
* </tr>
*
* </table>
*
* @see <a href="https://jakarta.ee/specifications/soap-attachments">Jakarta SOAP Specification</a>
Expand Down

0 comments on commit d8706c4

Please sign in to comment.