Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17549

Do not swallow exception cause when context refresh fails

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 5.0.4, 5.0.11
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Last commented by a User:
      true

      Description

      I have a bean that is failing to initialize and throwing an exception. The cause of the cause of the cause of that exception is the real, underlying issue.

      The exception propagates to AbstractApplicationContext.refresh, at which point it is logged as a warning:

      if (logger.isWarnEnabled()) {
         logger.warn("Exception encountered during context initialization - " +
               "cancelling refresh attempt: " + ex);
      }

      Note that the exception is being string-concatenated (and therefore toString'd), rather than passing the exception itself to the logger. This means that only the exception's type and message get written to the log, which in turn means that I only learn that my bean failed to initialize, but not why. It also means I get no stacktrace.

      The fix here is to replace the + with a ,. I'll be submitting a pull request shortly.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                jakerobb Jake Robb
                Last updater:
                Spring Issuemaster
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Days since last comment:
                  47 weeks, 5 days ago