JAMES-2180 Fix sporadically failing test because of too long debug lines

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ff7703f9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ff7703f9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ff7703f9

Branch: refs/heads/master
Commit: ff7703f99388b3486e805151940a9bc12576963f
Parents: 39828eb
Author: Raphael Ouazana <raphael.ouaz...@linagora.com>
Authored: Tue Oct 10 17:10:47 2017 +0200
Committer: benwa <btell...@linagora.com>
Committed: Wed Oct 11 10:08:49 2017 +0700

----------------------------------------------------------------------
 .../org/apache/james/backends/es/ElasticSearchIndexer.java     | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ff7703f9/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
----------------------------------------------------------------------
diff --git 
a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
 
b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
index d637be6..2716e89 100644
--- 
a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
+++ 
b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/ElasticSearchIndexer.java
@@ -24,6 +24,7 @@ import java.util.Optional;
 
 import javax.inject.Inject;
 
+import org.apache.commons.lang3.StringUtils;
 import org.elasticsearch.action.bulk.BulkRequestBuilder;
 import org.elasticsearch.action.bulk.BulkResponse;
 import org.elasticsearch.action.index.IndexResponse;
@@ -38,6 +39,7 @@ import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
 
 public class ElasticSearchIndexer {
+    private static int DEBUG_MAX_LENGTH_CONTENT = 1000;
 
     public static class UpdatedRepresentation {
         private final String id;
@@ -99,7 +101,9 @@ public class ElasticSearchIndexer {
     
     public IndexResponse indexMessage(String id, String content) {
         checkArgument(content);
-        LOGGER.debug("Indexing {}: {}", id, content);
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("Indexing {}: {}", id, StringUtils.left(content, 
DEBUG_MAX_LENGTH_CONTENT));
+        }
         return client.prepareIndex(indexName.getValue(), typeName.getValue(), 
id)
             .setSource(content)
             .get();


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to