UnsatisfiedDependencyException avoids duplicate nested exception message
Issue: SPR-14607
(cherry picked from commit 93d2287
)
This commit is contained in:
parent
7135bc2dc2
commit
f735d12247
|
@ -18,6 +18,7 @@ package org.springframework.beans.factory;
|
||||||
|
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when a bean depends on other beans or simple properties
|
* Exception thrown when a bean depends on other beans or simple properties
|
||||||
|
@ -46,7 +47,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
|
||||||
|
|
||||||
super(resourceDescription, beanName,
|
super(resourceDescription, beanName,
|
||||||
"Unsatisfied dependency expressed through bean property '" + propertyName + "'" +
|
"Unsatisfied dependency expressed through bean property '" + propertyName + "'" +
|
||||||
(msg != null ? ": " + msg : ""));
|
(StringUtils.hasLength(msg) ? ": " + msg : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,7 +60,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
|
||||||
public UnsatisfiedDependencyException(
|
public UnsatisfiedDependencyException(
|
||||||
String resourceDescription, String beanName, String propertyName, BeansException ex) {
|
String resourceDescription, String beanName, String propertyName, BeansException ex) {
|
||||||
|
|
||||||
this(resourceDescription, beanName, propertyName, (ex != null ? ex.getMessage() : ""));
|
this(resourceDescription, beanName, propertyName, "");
|
||||||
initCause(ex);
|
initCause(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +75,9 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
|
||||||
public UnsatisfiedDependencyException(
|
public UnsatisfiedDependencyException(
|
||||||
String resourceDescription, String beanName, InjectionPoint injectionPoint, String msg) {
|
String resourceDescription, String beanName, InjectionPoint injectionPoint, String msg) {
|
||||||
|
|
||||||
super(resourceDescription, beanName, "Unsatisfied dependency expressed through " + injectionPoint + ": " + msg);
|
super(resourceDescription, beanName,
|
||||||
|
"Unsatisfied dependency expressed through " + injectionPoint +
|
||||||
|
(StringUtils.hasLength(msg) ? ": " + msg : ""));
|
||||||
this.injectionPoint = injectionPoint;
|
this.injectionPoint = injectionPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +92,7 @@ public class UnsatisfiedDependencyException extends BeanCreationException {
|
||||||
public UnsatisfiedDependencyException(
|
public UnsatisfiedDependencyException(
|
||||||
String resourceDescription, String beanName, InjectionPoint injectionPoint, BeansException ex) {
|
String resourceDescription, String beanName, InjectionPoint injectionPoint, BeansException ex) {
|
||||||
|
|
||||||
this(resourceDescription, beanName, injectionPoint, (ex != null ? ex.getMessage() : ""));
|
this(resourceDescription, beanName, injectionPoint, "");
|
||||||
initCause(ex);
|
initCause(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue