SimpleStubFactory has to be more precise about supports()
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.grpc.client;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import io.grpc.stub.AbstractStub;
|
||||
@@ -23,8 +25,12 @@ public class SimpleStubFactory extends AbstractStubFactory<AbstractStub<?>> {
|
||||
|
||||
public static boolean supports(Class<?> type) {
|
||||
Class<?> factory = type.getEnclosingClass();
|
||||
return AbstractStubFactory.supports(AbstractStub.class, type) && factory != null
|
||||
&& ReflectionUtils.findMethod(factory, "newStub", (Class<?>[]) null) != null;
|
||||
return AbstractStubFactory.supports(AbstractStub.class, type) && factory != null && hasMethod(factory, type);
|
||||
}
|
||||
|
||||
private static boolean hasMethod(Class<?> factory, Class<?> type) {
|
||||
Method method = ReflectionUtils.findMethod(factory, "newStub", (Class<?>[]) null);
|
||||
return method != null && method.getReturnType().isAssignableFrom(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user