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

dlmarion pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/main by this push:
     new 35f44ed603 Applied fix from #5260 in other locations (#5305)
35f44ed603 is described below

commit 35f44ed60333fc61328d98f5926176141a7f50d5
Author: Dave Marion <dlmar...@apache.org>
AuthorDate: Wed Feb 5 09:28:10 2025 -0500

    Applied fix from #5260 in other locations (#5305)
    
    The issue fixed in #5260 was that a class that was implementing
    a Thrift interface had to declare it, even if it was declared
    in a parent class. #5260 fixed the logic in one place and then
    removed the interface declarations from the subclasses. It
    appears that there are other locations in the code where the
    same problem exists. This commit moves the fix to a utility
    class and updates the places where this was being done to use
    the utility method.
---
 .../org/apache/accumulo/core/trace/TraceUtil.java  | 16 +-------
 .../org/apache/accumulo/core/util/ClassUtil.java   | 44 ++++++++++++++++++++++
 .../server/rpc/HighlyAvailableServiceWrapper.java  |  3 +-
 .../server/rpc/TCredentialsUpdatingWrapper.java    |  3 +-
 4 files changed, 50 insertions(+), 16 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java 
b/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java
index 63d7a79307..77ba7fbc15 100644
--- a/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java
+++ b/core/src/main/java/org/apache/accumulo/core/trace/TraceUtil.java
@@ -21,15 +21,14 @@ package org.apache.accumulo.core.trace;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Proxy;
-import java.util.HashSet;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.Callable;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.clientImpl.thrift.TInfo;
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
+import org.apache.accumulo.core.util.ClassUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -216,19 +215,8 @@ public class TraceUtil {
   private static <T> T wrapRpc(final InvocationHandler handler, final T 
instance) {
     @SuppressWarnings("unchecked")
     T proxiedInstance = (T) 
Proxy.newProxyInstance(instance.getClass().getClassLoader(),
-        getInterfaces(instance.getClass()).toArray(new Class<?>[0]), handler);
+        ClassUtil.getInterfaces(instance.getClass()).toArray(new Class<?>[0]), 
handler);
     return proxiedInstance;
   }
 
-  private static Set<Class<?>> getInterfaces(Class<?> clazz) {
-    var set = new HashSet<Class<?>>();
-    if (clazz != null) {
-      set.addAll(getInterfaces(clazz.getSuperclass()));
-      for (Class<?> interfaze : clazz.getInterfaces()) {
-        set.add(interfaze);
-      }
-    }
-    return set;
-  }
-
 }
diff --git a/core/src/main/java/org/apache/accumulo/core/util/ClassUtil.java 
b/core/src/main/java/org/apache/accumulo/core/util/ClassUtil.java
new file mode 100644
index 0000000000..c95852bb41
--- /dev/null
+++ b/core/src/main/java/org/apache/accumulo/core/util/ClassUtil.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.core.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class ClassUtil {
+
+  /**
+   * Utility method to return the set of all interfaces implemented by the 
supplied class and it's
+   * parents.
+   *
+   * @param clazz Class object to check
+   * @return Set of interface classes implemented by input argument
+   */
+  public static Set<Class<?>> getInterfaces(Class<?> clazz) {
+    var set = new HashSet<Class<?>>();
+    if (clazz != null) {
+      set.addAll(getInterfaces(clazz.getSuperclass()));
+      for (Class<?> interfaze : clazz.getInterfaces()) {
+        set.add(interfaze);
+      }
+    }
+    return set;
+  }
+
+}
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/rpc/HighlyAvailableServiceWrapper.java
 
b/server/base/src/main/java/org/apache/accumulo/server/rpc/HighlyAvailableServiceWrapper.java
index e500104478..307b2dfa36 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/rpc/HighlyAvailableServiceWrapper.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/rpc/HighlyAvailableServiceWrapper.java
@@ -21,6 +21,7 @@ package org.apache.accumulo.server.rpc;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
 
+import org.apache.accumulo.core.util.ClassUtil;
 import org.apache.accumulo.server.HighlyAvailableService;
 
 /**
@@ -42,7 +43,7 @@ public class HighlyAvailableServiceWrapper {
 
     @SuppressWarnings("unchecked")
     I proxiedInstance = (I) 
Proxy.newProxyInstance(instance.getClass().getClassLoader(),
-        instance.getClass().getInterfaces(), handler);
+        ClassUtil.getInterfaces(instance.getClass()).toArray(new Class<?>[0]), 
handler);
     return proxiedInstance;
   }
 
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/rpc/TCredentialsUpdatingWrapper.java
 
b/server/base/src/main/java/org/apache/accumulo/server/rpc/TCredentialsUpdatingWrapper.java
index 1f84c3eedc..4e57aa8e0a 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/rpc/TCredentialsUpdatingWrapper.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/rpc/TCredentialsUpdatingWrapper.java
@@ -22,6 +22,7 @@ import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
 
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
+import org.apache.accumulo.core.util.ClassUtil;
 
 /**
  * Utility method to ensure that the instance of TCredentials which is passed 
to the implementation
@@ -37,7 +38,7 @@ public class TCredentialsUpdatingWrapper {
 
     @SuppressWarnings("unchecked")
     T proxiedInstance = (T) 
Proxy.newProxyInstance(originalClass.getClassLoader(),
-        originalClass.getInterfaces(), handler);
+        ClassUtil.getInterfaces(instance.getClass()).toArray(new Class<?>[0]), 
handler);
 
     return proxiedInstance;
   }

Reply via email to