4848public final class XmlDecoder extends DefaultObjectPipe <Reader , XmlReceiver > {
4949
5050 private static final String SAX_PROPERTY_LEXICAL_HANDLER = "http://xml.org/sax/properties/lexical-handler" ;
51- private XMLReader saxReader ;
52- private final SAXParserFactory parserFactory = SAXParserFactory . newInstance () ;
51+ private static final String TOTAL_ENTITY_SIZE_LIMIT = "http://www.oracle.com/xml/jaxp/properties/totalEntitySizeLimit" ;
52+ private final XMLReader saxReader ;
5353
5454 /**
5555 * Creates an instance of {@link XmlDecoder} by obtaining a new instance of an
5656 * {@link org.xml.sax.XMLReader}.
5757 */
5858 public XmlDecoder () {
5959 try {
60+ final SAXParserFactory parserFactory = SAXParserFactory .newInstance ();
6061 parserFactory .setNamespaceAware (true );
6162 saxReader = parserFactory .newSAXParser ().getXMLReader ();
6263 }
@@ -71,14 +72,13 @@ public XmlDecoder() {
7172 *
7273 * Defaults to "50,000,000". Set to "0" to allow unlimited entities.
7374 *
74- * @param size the size of the allowed entities. Set to "0" if entities should be unlimited.
75+ * @param totalEntitySizeLimit the size of the allowed entities. Set to "0" if entities should be unlimited.
7576 */
76- public void setTotalEntitySizeLimit (final String size ) {
77+ public void setTotalEntitySizeLimit (final String totalEntitySizeLimit ) {
7778 try {
78- System .setProperty ("jdk.xml.totalEntitySizeLimit" , size );
79- saxReader = parserFactory .newSAXParser ().getXMLReader ();
79+ saxReader .setProperty (TOTAL_ENTITY_SIZE_LIMIT , totalEntitySizeLimit );
8080 }
81- catch (final ParserConfigurationException | SAXException e ) {
81+ catch (final SAXException e ) {
8282 throw new MetafactureException (e );
8383 }
8484 }
0 commit comments