You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2019/07/24 12:21:38 UTC

[tika] branch master updated: avoid spamming logs

This is an automated email from the ASF dual-hosted git repository.

tallison pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tika.git


The following commit(s) were added to refs/heads/master by this push:
     new 5215fa6  avoid spamming logs
5215fa6 is described below

commit 5215fa69e882a7cf5a543497d8319a31324be790
Author: TALLISON <ta...@apache.org>
AuthorDate: Wed Jul 24 08:21:28 2019 -0400

    avoid spamming logs
---
 .../java/org/apache/tika/utils/XMLReaderUtils.java     | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/tika-core/src/main/java/org/apache/tika/utils/XMLReaderUtils.java b/tika-core/src/main/java/org/apache/tika/utils/XMLReaderUtils.java
index f7d100f..676eb67 100644
--- a/tika-core/src/main/java/org/apache/tika/utils/XMLReaderUtils.java
+++ b/tika-core/src/main/java/org/apache/tika/utils/XMLReaderUtils.java
@@ -507,6 +507,7 @@ public class XMLReaderUtils implements Serializable {
     private static PoolDOMBuilder acquireDOMBuilder()
             throws TikaException {
         int waiting = 0;
+        long lastWarn = -1;
         while (true) {
             PoolDOMBuilder builder = null;
             DOM_READ_WRITE_LOCK.readLock().lock();
@@ -520,8 +521,12 @@ public class XMLReaderUtils implements Serializable {
             if (builder != null) {
                 return builder;
             }
-            LOG.warn("Contention waiting for a DOMParser. "+
-                    "Consider increasing the XMLReaderUtils.POOL_SIZE");
+            if (lastWarn < 0 || System.currentTimeMillis() - lastWarn > 1000) {
+                //avoid spamming logs
+                LOG.warn("Contention waiting for a DOMParser. " +
+                        "Consider increasing the XMLReaderUtils.POOL_SIZE");
+                lastWarn = System.currentTimeMillis();
+            }
             waiting++;
 
             if (waiting > 3000) {
@@ -576,6 +581,7 @@ public class XMLReaderUtils implements Serializable {
     private static PoolSAXParser acquireSAXParser()
             throws TikaException {
         int waiting = 0;
+        long lastWarn = -1;
         while (true) {
             PoolSAXParser parser = null;
             SAX_READ_WRITE_LOCK.readLock().lock();
@@ -589,8 +595,12 @@ public class XMLReaderUtils implements Serializable {
             if (parser != null) {
                 return parser;
             }
-            LOG.warn("Contention waiting for a SAXParser. "+
-                    "Consider increasing the XMLReaderUtils.POOL_SIZE");
+            if (lastWarn < 0 || System.currentTimeMillis() - lastWarn > 1000) {
+                //avoid spamming logs
+                LOG.warn("Contention waiting for a SAXParser. " +
+                        "Consider increasing the XMLReaderUtils.POOL_SIZE");
+                lastWarn = System.currentTimeMillis();
+            }
             waiting++;
             if (waiting > 3000) {
                 //freshen the pool.  Something went very wrong...