From f158e23aa1001bb9ff0fd6deb3b217335d3a046c Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 27 Mar 2012 13:33:44 +0200 Subject: [PATCH] Improve logging of exception during server-side picocontainer startup --- sonar-core/src/main/java/org/sonar/core/PicoUtils.java | 4 ++-- .../main/java/org/sonar/server/platform/Platform.java | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/PicoUtils.java b/sonar-core/src/main/java/org/sonar/core/PicoUtils.java index 0b51d6b9e77..8a5599b1431 100644 --- a/sonar-core/src/main/java/org/sonar/core/PicoUtils.java +++ b/sonar-core/src/main/java/org/sonar/core/PicoUtils.java @@ -27,7 +27,7 @@ public final class PicoUtils { private PicoUtils() { } - static Throwable sanitize(RuntimeException t) { + public static Throwable sanitize(Throwable t) { Throwable result = t; Throwable cause = t.getCause(); if (t instanceof PicoLifecycleException && cause != null) { @@ -41,7 +41,7 @@ public final class PicoUtils { return result; } - public static void propagateStartupException(RuntimeException t) { + public static void propagateStartupException(Throwable t) { throw Throwables.propagate(sanitize(t)); } } diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index 682cd208416..e698c426cd7 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -101,8 +101,9 @@ public final class Platform { } catch (RuntimeException e) { // full stacktrace is lost by jruby. It must be logged now. - LoggerFactory.getLogger(getClass()).error(e.getMessage(), e); - PicoUtils.propagateStartupException(e); + Throwable initialException = PicoUtils.sanitize(e); + LoggerFactory.getLogger(getClass()).error(initialException.getMessage(), initialException); + PicoUtils.propagateStartupException(initialException); } } } @@ -118,8 +119,9 @@ public final class Platform { profiler.stop(); } catch (RuntimeException e) { // full stacktrace is lost by jruby. It must be logged now. - LoggerFactory.getLogger(getClass()).error(e.getMessage(), e); - PicoUtils.propagateStartupException(e); + Throwable initialException = PicoUtils.sanitize(e); + LoggerFactory.getLogger(getClass()).error(initialException.getMessage(), initialException); + PicoUtils.propagateStartupException(initialException); } } } -- 2.39.5