You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/12/15 00:41:39 UTC

[GitHub] [hadoop] pjfanning commented on a diff in pull request #5224: HADOOP-18575: make transformer factory more lenient

pjfanning commented on code in PR #5224:
URL: https://github.com/apache/hadoop/pull/5224#discussion_r1049105381


##########
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/XMLUtils.java:
##########
@@ -156,8 +156,18 @@ public static SAXTransformerFactory newSecureSAXTransformerFactory()
           throws TransformerConfigurationException {
     SAXTransformerFactory trfactory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
     trfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-    trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
-    trfactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
+    quietSet(trfactory, XMLConstants.ACCESS_EXTERNAL_DTD, "");
+    quietSet(trfactory, XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
     return trfactory;
   }
+
+  private static boolean quietSet(TransformerFactory transformerFactory, String name, Object value) {
+    try {
+      transformerFactory.setAttribute(name, value);
+      return true;
+    } catch (Exception|Error e) {
+      // ok to ignore

Review Comment:
   these logs can be noisy - when I've added similar code in Apache POI and elsewhere, users gripe about the same lines appearing in the log even if it isn't exactly a storm - could they be debug level logs?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org