@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2017 the original author or authors .
* Copyright 2002 - 2018 the original author or authors .
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -60,7 +60,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
@@ -60,7 +60,7 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
private String targetBeanName ;
/** Class of the target */
private Class < ? > targetClass ;
private volatile Class < ? > targetClass ;
/ * *
* BeanFactory that owns this TargetSource . We need to hold onto this
@ -120,19 +120,28 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
@@ -120,19 +120,28 @@ public abstract class AbstractBeanFactoryBasedTargetSource implements TargetSour
@Override
public synchronized Class < ? > getTargetClass ( ) {
if ( this . targetClass = = null & & this . beanFactory ! = null ) {
// Determine type of the target bean.
this . targetClass = this . beanFactory . getType ( this . targetBeanName ) ;
if ( this . targetClass = = null ) {
if ( logger . isTraceEnabled ( ) ) {
logger . trace ( "Getting bean with name '" + this . targetBeanName + "' in order to determine type" ) ;
public Class < ? > getTargetClass ( ) {
Class < ? > targetClass = this . targetClass ;
if ( targetClass ! = null ) {
return targetClass ;
}
synchronized ( this ) {
// Full check within synchronization, entering the BeanFactory interaction algorithm only once...
targetClass = this . targetClass ;
if ( targetClass = = null & & this . beanFactory ! = null ) {
// Determine type of the target bean.
targetClass = this . beanFactory . getType ( this . targetBeanName ) ;
if ( targetClass = = null ) {
if ( logger . isTraceEnabled ( ) ) {
logger . trace ( "Getting bean with name '" + this . targetBeanName + "' for type determination" ) ;
}
Object beanInstance = this . beanFactory . getBean ( this . targetBeanName ) ;
targetClass = beanInstance . getClass ( ) ;
}
Object beanInstance = this . beanFactory . getBean ( this . targetBeanName ) ;
this . targetClass = beanInstance . getClass ( ) ;
this . targetClass = targetClass ;
}
return targetClass ;
}
return this . targetClass ;
}
@Override