Skip to content

Commit a730b6e

Browse files
committed
Backported exception message refinements from 4.2.x
1 parent 6c4f0a4 commit a730b6e

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ else if (mbd.isPrototype()) {
331331
String scopeName = mbd.getScope();
332332
final Scope scope = this.scopes.get(scopeName);
333333
if (scope == null) {
334-
throw new IllegalStateException("No Scope registered for scope '" + scopeName + "'");
334+
throw new IllegalStateException("No Scope registered for scope name '" + scopeName + "'");
335335
}
336336
try {
337337
Object scopedInstance = scope.get(beanName, new ObjectFactory<Object>() {
@@ -350,8 +350,8 @@ public Object getObject() throws BeansException {
350350
}
351351
catch (IllegalStateException ex) {
352352
throw new BeanCreationException(beanName,
353-
"Scope '" + scopeName + "' is not active for the current thread; " +
354-
"consider defining a scoped proxy for this bean if you intend to refer to it from a singleton",
353+
"Scope '" + scopeName + "' is not active for the current thread; consider " +
354+
"defining a scoped proxy for this bean if you intend to refer to it from a singleton",
355355
ex);
356356
}
357357
}
@@ -1334,6 +1334,8 @@ public Class<?> run() throws Exception {
13341334

13351335
private Class<?> doResolveBeanClass(RootBeanDefinition mbd, Class<?>... typesToMatch) throws ClassNotFoundException {
13361336
if (!ObjectUtils.isEmpty(typesToMatch)) {
1337+
// When just doing type checks (i.e. not creating an actual instance yet),
1338+
// use the specified temporary class loader (e.g. in a weaving scenario).
13371339
ClassLoader tempClassLoader = getTempClassLoader();
13381340
if (tempClassLoader != null) {
13391341
if (tempClassLoader instanceof DecoratingClassLoader) {

spring-core/src/main/java/org/springframework/core/convert/ConversionFailedException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,8 @@ public final class ConversionFailedException extends ConversionException {
4343
* @param cause the cause of the conversion failure
4444
*/
4545
public ConversionFailedException(TypeDescriptor sourceType, TypeDescriptor targetType, Object value, Throwable cause) {
46-
super("Failed to convert from type " + sourceType + " to type " + targetType + " for value '" + ObjectUtils.nullSafeToString(value) + "'", cause);
46+
super("Failed to convert from type [" + sourceType + "] to type [" + targetType +
47+
"] for value '" + ObjectUtils.nullSafeToString(value) + "'", cause);
4748
this.sourceType = sourceType;
4849
this.targetType = targetType;
4950
this.value = value;

spring-core/src/main/java/org/springframework/core/convert/ConverterNotFoundException.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2010 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,9 +17,11 @@
1717
package org.springframework.core.convert;
1818

1919
/**
20-
* Thrown when a suitable converter could not be found in a conversion service.
20+
* Exception to be thrown when a suitable converter could not be found
21+
* in a given conversion service.
2122
*
2223
* @author Keith Donald
24+
* @author Juergen Hoeller
2325
* @since 3.0
2426
*/
2527
@SuppressWarnings("serial")
@@ -36,21 +38,21 @@ public final class ConverterNotFoundException extends ConversionException {
3638
* @param targetType the target type requested to convert to
3739
*/
3840
public ConverterNotFoundException(TypeDescriptor sourceType, TypeDescriptor targetType) {
39-
super("No converter found capable of converting from type " + sourceType + " to type " + targetType);
41+
super("No converter found capable of converting from type [" + sourceType + "] to type [" + targetType + "]");
4042
this.sourceType = sourceType;
4143
this.targetType = targetType;
4244
}
4345

4446

4547
/**
46-
* Returns the source type that was requested to convert from.
48+
* Return the source type that was requested to convert from.
4749
*/
4850
public TypeDescriptor getSourceType() {
4951
return this.sourceType;
5052
}
5153

5254
/**
53-
* Returns the target type that was requested to convert to.
55+
* Return the target type that was requested to convert to.
5456
*/
5557
public TypeDescriptor getTargetType() {
5658
return this.targetType;

0 commit comments

Comments
 (0)