dubbo icon indicating copy to clipboard operation
dubbo copied to clipboard

[Bug] dubbo-compiler bug ,An error occurs when the proto file does not match the service name

Open crazyStar00 opened this issue 1 year ago • 0 comments

Pre-check

  • [X] I am sure that all the content I provide is in English.

Search before asking

  • [X] I had searched in the issues and found no similar issues.

Apache Dubbo Component

Java SDK (apache/dubbo)

Dubbo Version

Dubbo Java 3.2.13 oracle jdk 1.8 window10

Steps to reproduce this issue

proto: echo.proto

syntax = "proto3";

package echo;
option java_package = "dcloud.common";
option java_multiple_files = true;

service EchoService {
  rpc echo (EchoRequest) returns (EchoResponse) {}
  rpc echo2 (EchoRequest) returns (EchoResponse) {}
}

message EchoRequest {
  string message = 1;
  string name = 2;
}

message EchoResponse {
  string message = 1;
  repeated Trace traces = 2;
}

The generated code image EchoServiceOuterClass class is not exists. EchoServiceOuterClass maby use Echo class replace Echo class code:


package dcloud.common;

public final class Echo {
  private Echo() {}
  public static void registerAllExtensions(
      com.google.protobuf.ExtensionRegistryLite registry) {
  }

  public static void registerAllExtensions(
      com.google.protobuf.ExtensionRegistry registry) {
    registerAllExtensions(
        (com.google.protobuf.ExtensionRegistryLite) registry);
  }
  static final com.google.protobuf.Descriptors.Descriptor
    internal_static_echo_EchoRequest_descriptor;
  static final 
    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internal_static_echo_EchoRequest_fieldAccessorTable;
  static final com.google.protobuf.Descriptors.Descriptor
    internal_static_echo_EchoResponse_descriptor;
  static final 
    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internal_static_echo_EchoResponse_fieldAccessorTable;
  static final com.google.protobuf.Descriptors.Descriptor
    internal_static_echo_Trace_descriptor;
  static final 
    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internal_static_echo_Trace_fieldAccessorTable;

  public static com.google.protobuf.Descriptors.FileDescriptor
      getDescriptor() {
    return descriptor;
  }
  private static  com.google.protobuf.Descriptors.FileDescriptor
      descriptor;
  static {
    java.lang.String[] descriptorData = {
      "\n\necho.proto\022\004echo\",\n\013EchoRequest\022\017\n\007mes" +
      "sage\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\"<\n\014EchoResponse" +
      "\022\017\n\007message\030\001 \001(\t\022\033\n\006traces\030\002 \003(\0132\013.echo" +
      ".Trace\"\025\n\005Trace\022\014\n\004host\030\001 \001(\t2p\n\013EchoSer" +
      "vice\022/\n\004echo\022\021.echo.EchoRequest\032\022.echo.E" +
      "choResponse\"\000\0220\n\005echo2\022\021.echo.EchoReques" +
      "t\032\022.echo.EchoResponse\"\000B\021\n\rdcloud.common" +
      "P\001b\006proto3"
    };
    descriptor = com.google.protobuf.Descriptors.FileDescriptor
      .internalBuildGeneratedFileFrom(descriptorData,
        new com.google.protobuf.Descriptors.FileDescriptor[] {
        });
    internal_static_echo_EchoRequest_descriptor =
      getDescriptor().getMessageTypes().get(0);
    internal_static_echo_EchoRequest_fieldAccessorTable = new
      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
        internal_static_echo_EchoRequest_descriptor,
        new java.lang.String[] { "Message", "Name", });
    internal_static_echo_EchoResponse_descriptor =
      getDescriptor().getMessageTypes().get(1);
    internal_static_echo_EchoResponse_fieldAccessorTable = new
      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
        internal_static_echo_EchoResponse_descriptor,
        new java.lang.String[] { "Message", "Traces", });
    internal_static_echo_Trace_descriptor =
      getDescriptor().getMessageTypes().get(2);
    internal_static_echo_Trace_fieldAccessorTable = new
      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
        internal_static_echo_Trace_descriptor,
        new java.lang.String[] { "Host", });
  }

  // @@protoc_insertion_point(outer_class_scope)
}

The issue was resolved when I renamed the proto file name from echo.proto to echoService.proto

I checked the dubco-compile code and found that this might be the problem image

What you expected to happen

Use the proto name when the proto file name is inconsistent with service, otherwise use service name +OuterClass

Anything else

No response

Are you willing to submit a pull request to fix on your own?

  • [X] Yes I am willing to submit a pull request on my own!

Code of Conduct

crazyStar00 avatar Jun 05 '24 01:06 crazyStar00