Skip to content

Commit

Permalink
Dubbo ProviderConsumerRegTable class cause outOfMemory while no provi…
Browse files Browse the repository at this point in the history
…der available exception occurs (#8522)

since create proxy error , so we must be the first consumer. Simply clear ConcurrentHashSet
  • Loading branch information
qixiaobo authored Aug 23, 2021
1 parent 86b5e00 commit f62ca3f
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.alibaba.dubbo.config.model.ApplicationModel;
import com.alibaba.dubbo.config.model.ConsumerModel;
import com.alibaba.dubbo.config.support.Parameter;
import com.alibaba.dubbo.registry.support.ConsumerInvokerWrapper;
import com.alibaba.dubbo.registry.support.ProviderConsumerRegTable;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.Protocol;
import com.alibaba.dubbo.rpc.ProxyFactory;
Expand All @@ -47,11 +49,13 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import static com.alibaba.dubbo.common.utils.NetUtils.isInvalidLocalHost;

Expand Down Expand Up @@ -423,7 +427,14 @@ private T createProxy(Map<String, String> map) {
if (c && !invoker.isAvailable()) {
// make it possible for consumer to retry later if provider is temporarily unavailable
initialized = false;
throw new IllegalStateException("Failed to check the status of the service " + interfaceName + ". No provider available for the service " + (group == null ? "" : group + "/") + interfaceName + (version == null ? "" : ":" + version) + " from the url " + invoker.getUrl() + " to the consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion());
final String serviceKey = (group == null ? "" : group + "/") + interfaceName + (version == null ? "" :
":" + version);
Set<ConsumerInvokerWrapper> consumerInvoker = ProviderConsumerRegTable.getConsumerInvoker(serviceKey);
if (consumerInvoker != Collections.<ConsumerInvokerWrapper>emptySet()) {
//since create proxy error , so we must be the first consumer. Simply clear ConcurrentHashSet
consumerInvoker.clear();
}
throw new IllegalStateException("Failed to check the status of the service " + interfaceName + ". No provider available for the service " + serviceKey + " from the url " + invoker.getUrl() + " to the consumer " + NetUtils.getLocalHost() + " use dubbo version " + Version.getVersion());
}
if (logger.isInfoEnabled()) {
logger.info("Refer dubbo service " + interfaceClass.getName() + " from url " + invoker.getUrl());
Expand Down

0 comments on commit f62ca3f

Please sign in to comment.