File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
opennlp-core/opennlp-runtime/src/main/java/opennlp/tools/util Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 2424import javax .xml .parsers .SAXParser ;
2525import javax .xml .parsers .SAXParserFactory ;
2626
27+ import org .slf4j .Logger ;
28+ import org .slf4j .LoggerFactory ;
2729import org .xml .sax .SAXException ;
2830
2931public class XmlUtil {
3032
33+ private static final Logger logger = LoggerFactory .getLogger (XmlUtil .class );
34+
3135 /**
3236 * Create a new {@link DocumentBuilder} which processes XML securely.
3337 *
@@ -38,7 +42,14 @@ public class XmlUtil {
3842 public static DocumentBuilder createDocumentBuilder () {
3943 try {
4044 DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance ();
41- documentBuilderFactory .setFeature (XMLConstants .FEATURE_SECURE_PROCESSING , true );
45+ try {
46+ documentBuilderFactory .setFeature (XMLConstants .FEATURE_SECURE_PROCESSING , true );
47+ } catch (ParserConfigurationException e ) {
48+ /// {@link XMLConstants.FEATURE_SECURE_PROCESSING} is not supported on Android.
49+ /// See {@link DocumentBuilderFactory#setFeature}
50+ logger .warn ("Failed to enable XMLConstants.FEATURE_SECURE_PROCESSING, it's unsupported on" +
51+ " this platform." , e );
52+ }
4253 return documentBuilderFactory .newDocumentBuilder ();
4354 } catch (ParserConfigurationException e ) {
4455 throw new IllegalStateException (e );
You can’t perform that action at this time.
0 commit comments