Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
crazyStar00 opened this issue Jun 5, 2024 · 0 comments
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage

Comments

@crazyStar00
Copy link
Contributor

Pre-check

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

Search before asking

  • 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?

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

Code of Conduct

@crazyStar00 crazyStar00 added component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage labels Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/need-triage Need maintainers to triage type/need-triage Need maintainers to triage
Projects
Status: Todo
Development

No branches or pull requests

1 participant