Skip to content

Same method name in difference services lead to error: "Multiple methods named 'send' are annotated with @ThriftMethod in the given services" #110

@symfu

Description

@symfu

Given two services:

@ThriftService
public interface ServiceOne {
    @ThriftMethod
    boolean send(String message);
}

@ThriftService
public interface ServiceTwo {
    @ThriftMethod
    boolean send(String message);
}

DriftServer will throw an exception complains that ""Multiple methods named 'send' are annotated with @ThriftMethod in the given services"".

It seems that difference services can't have a method with the same name?

Relative code (io/airlift/drift/server/DriftServerMethodInvoker.java:58):

package io.airlift.drift.server;
class DriftServerMethodInvoker implements ServerMethodInvoker {
    ...
    public DriftServerMethodInvoker(
            ThriftCodecManager codecManager,
            Collection<DriftService> services,
            List<MethodInvocationFilter> filters,
            MethodInvocationStatsFactory methodInvocationStatsFactory)
    {
        Map<String, ServiceMethod> processorMap = new HashMap<>();
        ImmutableMap.Builder<String, MethodInvocationStat> stats = ImmutableMap.builder();
        for (DriftService service : services) {
            ThriftServiceMetadata serviceMetadata = new ThriftServiceMetadata(service.getService().getClass(), codecManager.getCatalog());
            for (ThriftMethodMetadata thriftMethodMetadata : serviceMetadata.getMethods().values()) {
                if (processorMap.containsKey(thriftMethodMetadata.getName())) {

                    throw new IllegalArgumentException(format("Multiple methods named '%s' are annotated with @ThriftMethod in the given services", thriftMethodMetadata.getName()));
--------------------^  HERE

                }
                ServiceMethod serviceMethod = new ServiceMethod(codecManager, service.getService(), thriftMethodMetadata, filters);
                processorMap.put(thriftMethodMetadata.getName(), serviceMethod);
                if (service.isStatsEnabled()) {
                    stats.put(thriftMethodMetadata.getName(), methodInvocationStatsFactory.getStat(serviceMetadata, service.getQualifier(), serviceMethod.getMethodMetadata()));
                }
            }
        }
        ...
    }
` 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions