Skip to content

Distinguish between unsatisfied constructor and factory method deps - #965

Closed
wilkinsona wants to merge 1 commit into
spring-projects:masterfrom
wilkinsona:diagnostics
Closed

wilkinsona wants to merge 1 commit into
spring-projects:masterfrom
wilkinsona:diagnostics

Conversation

@wilkinsona

Copy link
Copy Markdown
Member

As discussed with @snicoll, and in support of Spring Boot 1.4's goal of providing improved diagnostics when application context refresh fails, this PR introduces specific exceptions for unsatisfied factory method dependencies and unsatisfied constructor dependencies.

Previously, an UnsatisfiedDependencyException was thrown when the
dependencies (arguments) of a constructor or a factory method could not
be satisfied. This had two drawbacks:

 1. The exception message for a failure for a factory method
    mentioned constructor arguments.
 2. The catcher of the exception had no way, short of parsing the
    message, to determine the exact nature of the failure.

This commit introduces two new UnsatisfiedDependencyException
subclasses – UnsatisfiedFactoryMethodDependencyException and
UnsatisfiedConstructorDependencyException. Each new exception provides
getters to access the method or constructor, and the index and type
of the unsatisfied argument.
@snicoll

snicoll commented Apr 12, 2016

Copy link
Copy Markdown
Member

@jhoeller has fixed this one already. Thanks for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants