private AbstractStub<?> createStub(final Class<? extends AbstractStub<?>> stubClass, final Channel channel) {
        final StubFactory factory = getStubFactories().stream()
                .filter(stubFactory -> stubFactory.isApplicable(stubClass))
                .findFirst()
                .orElseThrow(() -> new BeanInstantiationException(stubClass,
                        "Unsupported stub type: " + stubClass.getName() + " -> Please report this issue."));

        try {
            return factory.createStub(stubClass, channel);
        } catch (final Exception exception) {
            throw new BeanInstantiationException(stubClass, "Failed to create gRPC stub of type " + stubClass.getName(),
                    exception);
        }
    }
Creates a stub instance for the specified stub type using the resolved {@link StubFactory}.

@param stubClass The stub class that needs to be created.
@param channel The gRPC channel associated with the created stub, passed as a parameter to the stub factory.
@return A newly created gRPC stub.
@throws BeanInstantiationException If the stub couldn't be created, either because the type isn't supported or
        because of a failure in creation.
grpc-client-spring-boot-starter/src/main/java/net/devh/boot/grpc/client/inject/GrpcClientBeanPostProcessor.java