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

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit fcf224af07307f53547203ac87ef779c95489ef7
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Thu May 23 11:38:11 2019 +0700

    JAMES-2767 polish backend-es
---
 .../org/apache/james/backends/es/IndexCreationFactory.java  |  3 ++-
 .../apache/james/backends/es/ElasticSearchIndexerTest.java  | 13 ++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git 
a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
 
b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
index e0d10e0..993bfef 100644
--- 
a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
+++ 
b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/IndexCreationFactory.java
@@ -83,7 +83,8 @@ public class IndexCreationFactory {
             Preconditions.checkNotNull(indexName);
             try {
                 createIndexIfNeeded(client, indexName, 
generateSetting(nbShards, nbReplica));
-                aliases.forEach(Throwing.consumer(alias -> 
createAliasIfNeeded(client, indexName, alias)));
+                aliases.forEach(Throwing.<AliasName>consumer(alias -> 
createAliasIfNeeded(client, indexName, alias))
+                    .sneakyThrow());
             } catch (IOException e) {
                 LOGGER.error("Error while creating index : ", e);
             }
diff --git 
a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
 
b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
index f857f2c..b6eb880 100644
--- 
a/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
+++ 
b/backends-common/elasticsearch/src/test/java/org/apache/james/backends/es/ElasticSearchIndexerTest.java
@@ -21,10 +21,12 @@ package org.apache.james.backends.es;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.awaitility.Awaitility.await;
+import static org.awaitility.Duration.ONE_HUNDRED_MILLISECONDS;
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 
+import org.awaitility.Awaitility;
 import org.awaitility.Duration;
+import org.awaitility.core.ConditionFactory;
 import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.client.RequestOptions;
@@ -43,6 +45,11 @@ public class ElasticSearchIndexerTest {
     private static final IndexName INDEX_NAME = new IndexName("index_name");
     private static final WriteAliasName ALIAS_NAME = new 
WriteAliasName("alias_name");
 
+    private static final ConditionFactory CALMLY_AWAIT = Awaitility
+        .with().pollInterval(ONE_HUNDRED_MILLISECONDS)
+        .and().pollDelay(ONE_HUNDRED_MILLISECONDS)
+        .await();
+
     @Rule
     public DockerElasticSearchRule elasticSearch = new 
DockerElasticSearchRule();
     private ElasticSearchIndexer testee;
@@ -147,7 +154,7 @@ public class ElasticSearchIndexerTest {
         elasticSearch.awaitForElasticSearch();
         
         try (RestHighLevelClient client = getESClient()) {
-            await().atMost(Duration.TEN_SECONDS)
+            CALMLY_AWAIT.atMost(Duration.TEN_SECONDS)
                 .until(() -> client.search(
                         new SearchRequest(INDEX_NAME.getValue())
                             .source(new 
SearchSourceBuilder().query(QueryBuilders.matchAllQuery())),
@@ -178,7 +185,7 @@ public class ElasticSearchIndexerTest {
         elasticSearch.awaitForElasticSearch();
         
         try (RestHighLevelClient client = getESClient()) {
-            await().atMost(Duration.TEN_SECONDS)
+            CALMLY_AWAIT.atMost(Duration.TEN_SECONDS)
                 .until(() -> client.search(
                     new SearchRequest(INDEX_NAME.getValue())
                         .source(new 
SearchSourceBuilder().query(QueryBuilders.matchAllQuery())),


---------------------------------------------------------------------
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