Skip to content

Commit

Permalink
Ignore Exception when creating Reference (for generic call) (apache#8534
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AlbumenJ authored Aug 23, 2021
1 parent 0382a6b commit 89940b0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
import org.apache.dubbo.rpc.cluster.support.ClusterUtils;
import org.apache.dubbo.rpc.cluster.support.registry.ZoneAwareCluster;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.rpc.model.ServiceRepository;
import org.apache.dubbo.rpc.model.AsyncMethodInfo;
import org.apache.dubbo.rpc.model.ConsumerModel;
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.rpc.model.ServiceRepository;
import org.apache.dubbo.rpc.protocol.injvm.InjvmProtocol;
import org.apache.dubbo.rpc.service.GenericService;
import org.apache.dubbo.rpc.support.ProtocolUtils;
Expand Down Expand Up @@ -200,15 +200,14 @@ public synchronized T get() {

@Override
public synchronized void destroy() {
if (ref == null) {
return;
}
if (destroyed) {
return;
}
destroyed = true;
try {
invoker.destroy();
if (invoker != null) {
invoker.destroy();
}
} catch (Throwable t) {
logger.warn("Unexpected error occurred when destroy invoker of ReferenceConfig(" + url + ").", t);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1444,28 +1444,33 @@ private void referServices() {
}

configManager.getReferences().forEach(rc -> {
// TODO, compatible with ReferenceConfig.refer()
ReferenceConfig<?> referenceConfig = (ReferenceConfig<?>) rc;
referenceConfig.setBootstrap(this);
if (!referenceConfig.isRefreshed()) {
referenceConfig.refresh();
}

if (rc.shouldInit()) {
if (rc.shouldReferAsync()) {
ExecutorService executor = executorRepository.getServiceReferExecutor();
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
try {
cache.get(rc);
} catch (Throwable t) {
logger.error("refer async catch error : " + t.getMessage(), t);
}
}, executor);
try {
// TODO, compatible with ReferenceConfig.refer()
ReferenceConfig<?> referenceConfig = (ReferenceConfig<?>) rc;
referenceConfig.setBootstrap(this);
if (!referenceConfig.isRefreshed()) {
referenceConfig.refresh();
}

asyncReferringFutures.add(future);
} else {
cache.get(rc);
if (rc.shouldInit()) {
if (rc.shouldReferAsync()) {
ExecutorService executor = executorRepository.getServiceReferExecutor();
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
try {
cache.get(rc);
} catch (Throwable t) {
logger.error("refer async catch error : " + t.getMessage(), t);
}
}, executor);

asyncReferringFutures.add(future);
} else {
cache.get(rc);
}
}
} catch (Throwable t) {
logger.error("refer catch error", t);
cache.destroy(rc);
}
});
}
Expand Down

0 comments on commit 89940b0

Please sign in to comment.