You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/05/21 03:14:36 UTC
[james-project] 04/06: JAMES-2763 StartUpChecks should catch
exceptions during checking
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 ca24df5e7b8b48ebb8eef71be1d3cdbe16432447
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Mon May 20 15:28:02 2019 +0700
JAMES-2763 StartUpChecks should catch exceptions during checking
---
.../java/org/apache/james/StartUpChecksPerformer.java | 15 ++++++++++++++-
.../java/org/apache/james/StartUpChecksPerformerTest.java | 2 --
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/StartUpChecksPerformer.java b/server/container/guice/guice-common/src/main/java/org/apache/james/StartUpChecksPerformer.java
index 0dead1a..cbc52fa 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/StartUpChecksPerformer.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/StartUpChecksPerformer.java
@@ -182,10 +182,23 @@ public class StartUpChecksPerformer {
public List<StartUpCheck.CheckResult> check() {
return Flux.fromIterable(startUpChecks)
.publishOn(Schedulers.elastic())
- .map(StartUpCheck::check)
+ .map(this::checkQuietly)
.collect(Guavate.toImmutableList())
.block();
}
+
+ private StartUpCheck.CheckResult checkQuietly(StartUpCheck startUpCheck) {
+ try {
+ return startUpCheck.check();
+ } catch (Exception e) {
+ LOGGER.error("Error during the {} check", startUpCheck.checkName(), e);
+ return StartUpCheck.CheckResult.builder()
+ .checkName(startUpCheck.checkName())
+ .resultType(StartUpCheck.ResultType.BAD)
+ .description(e.getMessage())
+ .build();
+ }
+ }
}
private static final Logger LOGGER = LoggerFactory.getLogger(StartUpChecksPerformer.class);
diff --git a/server/container/guice/guice-common/src/test/java/org/apache/james/StartUpChecksPerformerTest.java b/server/container/guice/guice-common/src/test/java/org/apache/james/StartUpChecksPerformerTest.java
index 53b9064..cddb6e9 100644
--- a/server/container/guice/guice-common/src/test/java/org/apache/james/StartUpChecksPerformerTest.java
+++ b/server/container/guice/guice-common/src/test/java/org/apache/james/StartUpChecksPerformerTest.java
@@ -25,7 +25,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.apache.james.StartUpChecksPerformer.StartUpCheck.CheckResult;
import org.apache.james.StartUpChecksPerformer.StartUpCheck.ResultType;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
class StartUpChecksPerformerTest {
@@ -106,7 +105,6 @@ class StartUpChecksPerformerTest {
.containsOnly(BAD_CHECK_1, BAD_CHECK_2));
}
- @Disabled("performCheck() now doesn't support this")
@Test
void performCheckShouldNotPropagateUnExpectedExceptionDuringChecking() {
String checkName = "throwing check name";
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org