iohao / ioGame

无锁异步化、事件驱动架构设计的 java netty 网络编程框架; 轻量级,无需依赖任何第三方中间件或数据库就能支持集群、分布式; 适用于网络游戏服务器、物联网、内部系统及各种需要长连接的场景; 通过 ioGame 你可以很容易的搭建出一个集群无中心节点、集群自动化、分布式的网络服务器;FXGL、Unity、UE、Cocos Creator、Godot、Netty、Protobuf、webSocket、tcp、socket;java Netty 游戏服务器框架;
http://game.iohao.com
GNU Affero General Public License v3.0
904 stars 201 forks source link

请问下我在使用过程中在dto中string的属性无法pb序列化,还需要特殊处理吗?我看文中没有提到issue也没有 #238

Closed freshgeek closed 8 months ago

freshgeek commented 10 months ago

你的问题 | 使用场景


@ProtobufClass
public class Resp {
    int code;
    String msg;

    Object data;

    private Resp(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Resp() {
    }

    public static Resp success(Object data) {
        return new Resp(0, "成功", data);
    }

    public static Resp success() {
        return success(null);
    }
}

19:12:40.318 [RequestMessage-8-5] ERROR CommonStdout - Invalid class [java.lang.String] no field use annotation @com.baidu.bjf.remoting.protobuf.annotation.Protobuf at class java.lang.String
java.lang.IllegalArgumentException: Invalid class [java.lang.String] no field use annotation @com.baidu.bjf.remoting.protobuf.annotation.Protobuf at class java.lang.String
    at com.baidu.bjf.remoting.protobuf.utils.ProtobufProxyUtils.fetchFieldInfos(ProtobufProxyUtils.java:120)
    at com.baidu.bjf.remoting.protobuf.code.AbstractCodeGenerator.<init>(AbstractCodeGenerator.java:75)
    at com.baidu.bjf.remoting.protobuf.code.TemplateCodeGenerator.<init>(TemplateCodeGenerator.java:69)
    at com.baidu.bjf.remoting.protobuf.ProtobufProxy.getCodeGenerator(ProtobufProxy.java:389)
    at com.baidu.bjf.remoting.protobuf.ProtobufProxy.create(ProtobufProxy.java:155)
    at com.baidu.bjf.remoting.protobuf.ProtobufProxy.create(ProtobufProxy.java:128)
    at com.baidu.bjf.remoting.protobuf.code.CodedConstant.writeObject(CodedConstant.java:777)
    at com.baidu.bjf.remoting.protobuf.code.CodedConstant.writeObject(CodedConstant.java:754)
    at org.geek.chen.game.upgradation.common.rsp.Resp$$JProtoBufClass.doWriteTo(Resp$$JProtoBufClass.java:94)
    at org.geek.chen.game.upgradation.common.rsp.Resp$$JProtoBufClass.encode(Resp$$JProtoBufClass.java:30)
    at org.geek.chen.game.upgradation.common.rsp.Resp$$JProtoBufClass.encode(Resp$$JProtoBufClass.java:24)
    at com.iohao.game.common.kit.ProtoKit.toBytes(ProtoKit.java:54)
    at com.iohao.game.action.skeleton.core.codec.ProtoDataCodec.encode(ProtoDataCodec.java:36)
    at com.iohao.game.action.skeleton.core.DataCodecKit.encode(DataCodecKit.java:50)
    at com.iohao.game.action.skeleton.protocol.BarMessage.setData(BarMessage.java:80)
    at com.iohao.game.action.skeleton.core.flow.interal.DefaultActionMethodResultWrap.wrap(DefaultActionMethodResultWrap.java:75)
    at com.iohao.game.action.skeleton.core.DefaultActionCommandFlowExecute.execute(DefaultActionCommandFlowExecute.java:68)
    at com.iohao.game.action.skeleton.core.ActionCommandHandler.handler(ActionCommandHandler.java:41)
    at com.iohao.game.action.skeleton.core.BarSkeleton.handle(BarSkeleton.java:106)
    at com.iohao.game.bolt.broker.core.common.processor.hook.DefaultRequestMessageClientProcessorHook.lambda$processLogic$0(DefaultRequestMessageClientProcessorHook.java:66)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

预期值

期望的预期值

实际值

实际值

iohao commented 10 months ago

这部分可以尝试到 jprotobuf 社区讨论。