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 rc...@apache.org on 2019/11/29 02:00:32 UTC
[james-project] 06/06: JAMES-2996 Errors upon start should be
reported to the logging system
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4a8cd1ab9a08f2aecd3b6e8db98ebddd0e93cb78
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Nov 28 09:28:04 2019 +0700
JAMES-2996 Errors upon start should be reported to the logging system
log then rethrow pattern is the only solution to do this while still pro-
pagating the error.
---
.../java/org/apache/james/GuiceJamesServer.java | 23 +++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
index 85311fd..84611d7 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/GuiceJamesServer.java
@@ -31,6 +31,8 @@ import org.apache.james.server.core.configuration.Configuration;
import org.apache.james.utils.GuiceProbe;
import org.apache.james.utils.GuiceProbeProvider;
import org.apache.james.utils.InitializationOperations;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.Iterables;
import com.google.inject.Guice;
@@ -41,6 +43,7 @@ import com.google.inject.TypeLiteral;
import com.google.inject.util.Modules;
public class GuiceJamesServer {
+ private static final Logger LOGGER = LoggerFactory.getLogger(GuiceJamesServer.class);
protected final Module module;
private final IsStartedProbe isStartedProbe;
@@ -76,13 +79,19 @@ public class GuiceJamesServer {
}
public void start() throws Exception {
- Injector injector = Guice.createInjector(module);
- preDestroy = injector.getInstance(Key.get(new TypeLiteral<Stager<PreDestroy>>() {}));
- injector.getInstance(StartUpChecksPerformer.class)
- .performCheck();
- injector.getInstance(InitializationOperations.class).initModules();
- guiceProbeProvider = injector.getInstance(GuiceProbeProvider.class);
- isStartedProbe.notifyStarted();
+ try {
+ Injector injector = Guice.createInjector(module);
+ preDestroy = injector.getInstance(Key.get(new TypeLiteral<Stager<PreDestroy>>() {
+ }));
+ injector.getInstance(StartUpChecksPerformer.class)
+ .performCheck();
+ injector.getInstance(InitializationOperations.class).initModules();
+ guiceProbeProvider = injector.getInstance(GuiceProbeProvider.class);
+ isStartedProbe.notifyStarted();
+ } catch (Throwable e) {
+ LOGGER.error("Fatal error while starting James", e);
+ throw e;
+ }
}
public void stop() {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org