Cache interfaceClass in advance to prevent IndexOutOfBoundsException (#12567)
This commit is contained in:
parent
33edc4f170
commit
f81c3f3a44
|
|
@ -36,6 +36,7 @@ import static org.apache.dubbo.common.constants.LoggerCodeConstants.CLUSTER_FAIL
|
|||
*/
|
||||
public class StaticDirectory<T> extends AbstractDirectory<T> {
|
||||
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(StaticDirectory.class);
|
||||
private final Class<T> interfaceClass;
|
||||
|
||||
public StaticDirectory(List<Invoker<T>> invokers) {
|
||||
this(null, invokers, null);
|
||||
|
|
@ -55,11 +56,12 @@ public class StaticDirectory<T> extends AbstractDirectory<T> {
|
|||
throw new IllegalArgumentException("invokers == null");
|
||||
}
|
||||
this.setInvokers(new BitList<>(invokers));
|
||||
this.interfaceClass = invokers.get(0).getInterface();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<T> getInterface() {
|
||||
return getInvokers().get(0).getInterface();
|
||||
return interfaceClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue