This is an automated email from the ASF dual-hosted git repository.

zrlw pushed a commit to branch 3.3
in repository https://gitbox.apache.org/repos/asf/dubbo.git


The following commit(s) were added to refs/heads/3.3 by this push:
     new 5c0bd7f2c0 fixed the issue that the file name of message.proto is not 
supported (#15655)
5c0bd7f2c0 is described below

commit 5c0bd7f2c02447c36a1d6b2de85562c1bf8d8a7c
Author: changhao.ni <[email protected]>
AuthorDate: Wed Sep 24 16:52:50 2025 +0800

    fixed the issue that the file name of message.proto is not supported 
(#15655)
    
    * fixed the issue that the file name of message.proto is not supported
    
    * add unit test
    
    ---------
    
    Co-authored-by: earthchen <[email protected]>
---
 .../src/main/proto/message.proto                   | 40 ++++++++++++++++++++++
 .../springboot/idl/demo/MessageServiceTest.java    | 40 ++++++++++++++++++++++
 .../resources/Dubbo3TripleInterfaceStub.mustache   |  6 +++-
 .../src/main/resources/Dubbo3TripleStub.mustache   | 14 ++++----
 .../MutinyDubbo3TripleInterfaceStub.mustache       |  7 +++-
 .../main/resources/MutinyDubbo3TripleStub.mustache |  9 +++--
 .../ReactorDubbo3TripleInterfaceStub.mustache      |  7 +++-
 .../resources/ReactorDubbo3TripleStub.mustache     |  9 +++--
 8 files changed, 111 insertions(+), 21 deletions(-)

diff --git 
a/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/proto/message.proto
 
b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/proto/message.proto
new file mode 100644
index 0000000000..3e657752a0
--- /dev/null
+++ 
b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/main/proto/message.proto
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.dubbo.demo.message";
+option java_outer_classname = "Message";
+option objc_class_prefix = "HLW";
+
+package message;
+
+// The request message containing the user's name.
+message HelloRequest {
+    string name = 1;
+}
+
+// The response message containing the greetings.
+message HelloReply {
+    string message = 1;
+}
+
+// Service definition.
+service MessageService {
+    // Sends a greeting.
+    rpc sayHello(HelloRequest) returns (HelloReply);
+}
diff --git 
a/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/test/java/org/apache/dubbo/springboot/idl/demo/MessageServiceTest.java
 
b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/test/java/org/apache/dubbo/springboot/idl/demo/MessageServiceTest.java
new file mode 100644
index 0000000000..4932bbb4da
--- /dev/null
+++ 
b/dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/src/test/java/org/apache/dubbo/springboot/idl/demo/MessageServiceTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.springboot.idl.demo;
+
+import org.apache.dubbo.demo.message.DubboMessageServiceTriple;
+import org.apache.dubbo.rpc.protocol.tri.service.SchemaDescriptorRegistry;
+
+import com.google.protobuf.Descriptors.FileDescriptor;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+public class MessageServiceTest {
+
+    @Test
+    public void testMessageGenerator() {
+        try {
+            // load class
+            Class.forName(DubboMessageServiceTriple.class.getName());
+        } catch (ClassNotFoundException ignored) {
+        }
+        FileDescriptor schemaDescriptor =
+                
SchemaDescriptorRegistry.getSchemaDescriptor(DubboMessageServiceTriple.SERVICE_NAME);
+        Assertions.assertNotNull(schemaDescriptor);
+        Assertions.assertEquals("message.proto", schemaDescriptor.getName());
+    }
+}
diff --git 
a/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache
 
b/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache
index ccc00ce0ed..26c8e7bb5a 100644
--- 
a/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache
+++ 
b/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleInterfaceStub.mustache
@@ -23,7 +23,6 @@ import org.apache.dubbo.common.stream.StreamObserver;
 import org.apache.dubbo.remoting.http12.HttpMethods;
 import org.apache.dubbo.remoting.http12.rest.Mapping;
 import org.apache.dubbo.rpc.stub.annotations.GRequest;
-import com.google.protobuf.Message;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -32,7 +31,12 @@ import java.util.concurrent.CompletableFuture;
 
 public interface {{interfaceClassName}} extends 
org.apache.dubbo.rpc.model.DubboStub {
 
+{{#packageName}}
     String JAVA_SERVICE_NAME = "{{packageName}}.{{serviceName}}";
+{{/packageName}}
+{{^packageName}}
+    String JAVA_SERVICE_NAME = "{{serviceName}}";
+{{/packageName}}
 {{#commonPackageName}}
     String SERVICE_NAME = "{{commonPackageName}}.{{serviceName}}";
 {{/commonPackageName}}
diff --git 
a/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleStub.mustache 
b/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleStub.mustache
index 800aaf4a20..4bdf318303 100644
--- a/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleStub.mustache
+++ b/dubbo-plugin/dubbo-compiler/src/main/resources/Dubbo3TripleStub.mustache
@@ -39,8 +39,6 @@ import org.apache.dubbo.rpc.stub.StubMethodHandler;
 import org.apache.dubbo.rpc.stub.StubSuppliers;
 import org.apache.dubbo.rpc.stub.UnaryStubMethodHandler;
 
-import com.google.protobuf.Message;
-
 import java.util.HashMap;
 import java.util.Map;
 import java.util.function.BiConsumer;
@@ -68,38 +66,38 @@ public final class {{className}} {
 
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
     {{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.UNARY,
-    obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+    obj -> ((com.google.protobuf.Message) obj).toByteArray(),obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
     {{outputType}}::parseFrom);
 
     private static final StubMethodDescriptor {{methodName}}AsyncMethod = new 
StubMethodDescriptor("{{originMethodName}}",
     {{inputType}}.class, java.util.concurrent.CompletableFuture.class, 
MethodDescriptor.RpcType.UNARY,
-    obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+    obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
     {{outputType}}::parseFrom);
 
     private static final StubMethodDescriptor {{methodName}}ProxyAsyncMethod = 
new StubMethodDescriptor("{{originMethodName}}Async",
     {{inputType}}.class, {{outputType}}.class, MethodDescriptor.RpcType.UNARY,
-    obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+    obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
     {{outputType}}::parseFrom);
 {{/unaryMethods}}
 {{#serverStreamingMethods}}
 
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
     {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.SERVER_STREAM,
-    obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+    obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
     {{outputType}}::parseFrom);
 {{/serverStreamingMethods}}
 {{#clientStreamingMethods}}
 
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
     {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.CLIENT_STREAM,
-    obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+    obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
     {{outputType}}::parseFrom);
 {{/clientStreamingMethods}}
 {{#biStreamingWithoutClientStreamMethods}}
 
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
     {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.BI_STREAM,
-    obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+    obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
     {{outputType}}::parseFrom);
 {{/biStreamingWithoutClientStreamMethods}}
 
diff --git 
a/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleInterfaceStub.mustache
 
b/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleInterfaceStub.mustache
index f23072d8d2..5e7dd1b698 100644
--- 
a/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleInterfaceStub.mustache
+++ 
b/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleInterfaceStub.mustache
@@ -24,12 +24,17 @@ import io.smallrye.mutiny.Uni;
 
 public interface {{interfaceClassName}} extends 
org.apache.dubbo.rpc.model.DubboStub {
 
+{{#packageName}}
     String JAVA_SERVICE_NAME = "{{packageName}}.{{serviceName}}";
+{{/packageName}}
+{{^packageName}}
+    String JAVA_SERVICE_NAME = "{{serviceName}}";
+{{/packageName}}
 {{#commonPackageName}}
     String SERVICE_NAME = "{{commonPackageName}}.{{serviceName}}";
 {{/commonPackageName}}
 {{^commonPackageName}}
-    String SERVICE_NAME = "{{commonPackageName}}.{{serviceName}}";
+    String SERVICE_NAME = "{{serviceName}}";
 {{/commonPackageName}}
 {{#methods}}
     {{#javaDoc}}
diff --git 
a/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleStub.mustache
 
b/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleStub.mustache
index 1f3900105f..33c30c7858 100644
--- 
a/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleStub.mustache
+++ 
b/dubbo-plugin/dubbo-compiler/src/main/resources/MutinyDubbo3TripleStub.mustache
@@ -19,7 +19,6 @@
 package {{packageName}};
 {{/packageName}}
 
-import com.google.protobuf.Message;
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.PathResolver;
@@ -72,7 +71,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.UNARY,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/unaryMethods}}
 
@@ -82,7 +81,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.SERVER_STREAM,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/serverStreamingMethods}}
 
@@ -92,7 +91,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.CLIENT_STREAM,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/clientStreamingMethods}}
 
@@ -102,7 +101,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.BI_STREAM,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/biStreamingWithoutClientStreamMethods}}
 
diff --git 
a/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache
 
b/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache
index 59114929e5..f7e8764cf6 100644
--- 
a/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache
+++ 
b/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleInterfaceStub.mustache
@@ -24,12 +24,17 @@ import reactor.core.publisher.Mono;
 
 public interface {{interfaceClassName}} extends 
org.apache.dubbo.rpc.model.DubboStub {
 
+{{#packageName}}
     String JAVA_SERVICE_NAME = "{{packageName}}.{{serviceName}}";
+{{/packageName}}
+{{^packageName}}
+    String JAVA_SERVICE_NAME = "{{serviceName}}";
+{{/packageName}}
 {{#commonPackageName}}
     String SERVICE_NAME = "{{commonPackageName}}.{{serviceName}}";
 {{/commonPackageName}}
 {{^commonPackageName}}
-    String SERVICE_NAME = "{{commonPackageName}}.{{serviceName}}";
+    String SERVICE_NAME = "{{serviceName}}";
 {{/commonPackageName}}
 {{#methods}}
     {{#javaDoc}}
diff --git 
a/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleStub.mustache
 
b/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleStub.mustache
index 16ac2a4170..6003703c03 100644
--- 
a/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleStub.mustache
+++ 
b/dubbo-plugin/dubbo-compiler/src/main/resources/ReactorDubbo3TripleStub.mustache
@@ -19,7 +19,6 @@
 package {{packageName}};
 {{/packageName}}
 
-import com.google.protobuf.Message;
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.rpc.Invoker;
 import org.apache.dubbo.rpc.PathResolver;
@@ -72,7 +71,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.UNARY,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/unaryMethods}}
 
@@ -82,7 +81,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.SERVER_STREAM,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/serverStreamingMethods}}
 
@@ -92,7 +91,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.CLIENT_STREAM,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/clientStreamingMethods}}
 
@@ -102,7 +101,7 @@ public final class {{className}} {
     {{/javaDoc}}
     private static final StubMethodDescriptor {{methodName}}Method = new 
StubMethodDescriptor("{{originMethodName}}",
         {{inputType}}.class, {{outputType}}.class, 
MethodDescriptor.RpcType.BI_STREAM,
-        obj -> ((Message) obj).toByteArray(), obj -> ((Message) 
obj).toByteArray(), {{inputType}}::parseFrom,
+        obj -> ((com.google.protobuf.Message) obj).toByteArray(), obj -> 
((com.google.protobuf.Message) obj).toByteArray(), {{inputType}}::parseFrom,
         {{outputType}}::parseFrom);
 {{/biStreamingWithoutClientStreamMethods}}
 

Reply via email to