Skip to content

Commit

Permalink
Check if initialized for ReferenceBean (#12723)
Browse files Browse the repository at this point in the history
* Check if initialized for ReferenceBean

* fix name
  • Loading branch information
AlbumenJ authored Jul 14, 2023
1 parent 976ffda commit e322b17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@
import java.beans.Transient;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.TreeSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.TreeSet;

import static org.apache.dubbo.common.constants.CommonConstants.ANY_VALUE;
import static org.apache.dubbo.common.constants.CommonConstants.CLUSTER_KEY;
Expand Down Expand Up @@ -796,6 +796,17 @@ private void postProcessConfig() {
configPostProcessors.forEach(component -> component.postProcessReferConfig(this));
}

/**
* Return if ReferenceConfig has been initialized
* Note: Cannot use `isInitilized` as it may be treated as a Java Bean property
*
* @return initialized
*/
@Transient
public boolean configInitialized() {
return initialized;
}

/**
* just for test
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ private Object getCallProxy() throws Exception {
//Subclasses should synchronize on the given Object if they perform any sort of extended singleton creation phase.
// In particular, subclasses should not have their own mutexes involved in singleton creation, to avoid the potential for deadlocks in lazy-init situations.
//The redundant type cast is to be compatible with earlier than spring-4.2
if (referenceConfig.configInitialized()) {
return referenceConfig.get();
}
synchronized (((DefaultSingletonBeanRegistry)getBeanFactory()).getSingletonMutex()) {
return referenceConfig.get();
}
Expand Down

0 comments on commit e322b17

Please sign in to comment.