Skip to content

Commit

Permalink
use equal explicit class to replace anonymous class (#4027)
Browse files Browse the repository at this point in the history
  • Loading branch information
tswstarplanet authored and ralf0131 committed May 12, 2019
1 parent 309b694 commit 6a3f4c7
Showing 1 changed file with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,10 @@
*/
package org.apache.dubbo.rpc.cluster.support;

import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.Result;
import org.apache.dubbo.rpc.RpcException;
import org.apache.dubbo.rpc.cluster.Cluster;
import org.apache.dubbo.rpc.cluster.Directory;
import org.apache.dubbo.rpc.cluster.LoadBalance;

import java.util.List;

/**
* AvailableCluster
Expand All @@ -36,19 +31,7 @@ public class AvailableCluster implements Cluster {

@Override
public <T> Invoker<T> join(Directory<T> directory) throws RpcException {

return new AbstractClusterInvoker<T>(directory) {
@Override
public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
for (Invoker<T> invoker : invokers) {
if (invoker.isAvailable()) {
return invoker.invoke(invocation);
}
}
throw new RpcException("No provider available in " + invokers);
}
};

return new AvailableClusterInvoker<>(directory);
}

}

0 comments on commit 6a3f4c7

Please sign in to comment.