This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.2 by this push:
     new f81c3f3a44 Cache interfaceClass in advance to prevent 
IndexOutOfBoundsException (#12567)
f81c3f3a44 is described below

commit f81c3f3a44d3bd634f4f63fce83b0bcbaae86040
Author: Albumen Kevin <[email protected]>
AuthorDate: Mon Jun 19 18:56:01 2023 +0800

    Cache interfaceClass in advance to prevent IndexOutOfBoundsException 
(#12567)
---
 .../java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java
 
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java
index 8a17dc0fc0..36e3d3eb59 100644
--- 
a/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java
+++ 
b/dubbo-cluster/src/main/java/org/apache/dubbo/rpc/cluster/directory/StaticDirectory.java
@@ -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

Reply via email to