poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cen...@apache.org
Subject svn commit: r1776067 - /poi/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java
Date Mon, 26 Dec 2016 19:51:42 GMT
Author: centic
Date: Mon Dec 26 19:51:42 2016
New Revision: 1776067

URL: http://svn.apache.org/viewvc?rev=1776067&view=rev
Log:
Add some throttling to the log for failed SAXHelper features to not spam the log on JDK 9
with restricted reflection

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java?rev=1776067&r1=1776066&r2=1776067&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java Mon Dec 26 19:51:42 2016
@@ -20,6 +20,7 @@ package org.apache.poi.util;
 import java.io.IOException;
 import java.io.StringReader;
 import java.lang.reflect.Method;
+import java.util.concurrent.TimeUnit;
 
 import javax.xml.XMLConstants;
 import javax.xml.parsers.ParserConfigurationException;
@@ -36,6 +37,7 @@ import org.xml.sax.XMLReader;
  */
 public final class SAXHelper {
     private static POILogger logger = POILogFactory.getLogger(SAXHelper.class);
+    private static long lastLog = 0;
 
     private SAXHelper() {}
 
@@ -89,7 +91,10 @@ public final class SAXHelper {
                 // Stop once one can be setup without error
                 return;
             } catch (Throwable e) {     // NOSONAR - also catch things like NoClassDefError
here
-                logger.log(POILogger.WARN, "SAX Security Manager could not be setup", e);
+                // throttle the log somewhat as it can spam the log otherwise
+                if(System.currentTimeMillis() > lastLog + TimeUnit.MINUTES.toMillis(5))
{
+                    logger.log(POILogger.WARN, "SAX Security Manager could not be setup [log
suppressed for 5 minutes]", e);
+                }
             }
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message