Closed chaoyoung closed 8 months ago
麻烦贴一下你的 interface 定义
@EarthChen interface定义由proto文件编译生成:
Debug:
这里的MethodDescriptor实现类是StubMethodDescriptor,这个类中的getMethod()方法返回null,导致了NPE问题。请问如何修复。
升级一下 compiler 版本,保持和dubbo 版本一致即可
@EarthChen compiler版本和dubbo版本是一致的。
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.6.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
<protocPlugins>
<protocPlugin>
<id>dubbo</id>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-compiler</artifactId>
<version>${dubbo.version}</version>
<mainClass>org.apache.dubbo.gen.tri.Dubbo3TripleGenerator</mainClass>
</protocPlugin>
</protocPlugins>
</configuration>
<!-- ...-->
</plugin>
syntax = "proto3";
option java_multiple_files = true;
option java_package = "org.example.dubbo.rpc";
option java_outer_classname = "VoiceChatProto";
package org.example.dubbo.chat;
service VoiceChat {
rpc chat(stream VoiceChatRequest) returns (stream VoiceChatResponse);
}
message VoiceChatRequest {
string callId = 1;
bytes data = 3;
}
message VoiceChatResponse {
string callId = 1;
bytes data = 2;
}
ps: 这里java_package和package的值不一样
option java_package = "org.example.dubbo.rpc";
package org.example.dubbo.chat;
客户端使用java_package的path导致了server端NPE
ReferenceConfig<VoiceChat> ref = new ReferenceConfig<>();
ref.setInterface(VoiceChat.class);
ref.setProtocol("tri");
ref.setVersion("1.0");
ref.setUrl("tri://localhost:50051/org.example.dubbo.rpc.VoiceChat");
复现步骤:
git clone https://github.com/chaoyoung/dubbo-demo.git
mvn clean compile
org.example.dubbo.VoiceChatProvider#main
org.example.dubbo.VoiceChatConsumer#main
因为你定义了 package 所以path 应该是org.example.dubbo.chat,java_package 只是个java 侧的包路径,不作为请求path
npe 问题我们会优化一下提示
No news is good news. Please feel free to create a new issue if you have any question.
Environment
Steps
Triple client 在连接和断开Triple server时,server端分别出现NPE。
Expected Behavior
No NPE
Actual Behavior
NPE
exception trace: