Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public <T> T getBean(String name, Class<T> requiredType) throws BeansException {
public <T> T getBean(String name, ParameterizedTypeReference<T> typeReference) throws BeansException {
Object bean = getBean(name);
Type requiredType = typeReference.getType();
if (!ResolvableType.forType(requiredType).isInstance(bean)) {
if (!isTypeMatch(name, ResolvableType.forType(requiredType), true)) {
throw new BeanNotOfRequiredTypeException(name, requiredType, bean.getClass());
}
return (T) bean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.ParameterizedTypeReference;

/**
* @author Stephane Nicoll
* @author Yanming Zhou
*/
class ExpressionCachingIntegrationTests {

@Test // SPR-11692
@SuppressWarnings("unchecked")
void expressionIsCacheBasedOnActualMethod() {
ConfigurableApplicationContext context =
new AnnotationConfigApplicationContext(SharedConfig.class, Spr11692Config.class);

BaseDao<User> userDao = (BaseDao<User>) context.getBean("userDao");
BaseDao<Order> orderDao = (BaseDao<Order>) context.getBean("orderDao");
BaseDao<User> userDao = context.getBean("userDao", new ParameterizedTypeReference<>() {});
BaseDao<Order> orderDao = context.getBean("orderDao", new ParameterizedTypeReference<>() {});

userDao.persist(new User("1"));
orderDao.persist(new Order("2"));
Expand Down