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

在goClient调用javaserver的时候,会遇到java server获取到的请求的入参为空的情况。 #292

Closed
zhushengjun-it opened this issue Nov 26, 2021 · 2 comments

Comments

@zhushengjun-it
Copy link

What happened:
go-mod:
go 1.15

  require (
    dubbo.apache.org/dubbo-go/v3 v3.0.0-rc4-1.0.20211116041552-b90089d8b8a3
    github.com/apache/dubbo-go-hessian2 v1.9.3
 )

What you expected to happen:
go client调用javaserver时,javaserver获取到的接口的入参为空的情况。
How to reproduce it (as minimally and precisely as possible):
server:

     public class BaseTestRpcBO implements Serializable {

             private LigoLastMsgInfo ligoLastMsgInfo;

             private long testId;

             private String testContent;

             private Map<String, String> testMap;

             protected Set<String> testSet = new LinkedHashSet<>();

             private Date testDateTime;

             }

             public class LigoLastMsgInfo implements Serializable {

                 private static final long serialVersionUID = -1295732691903413324L;

                 private long messageId;

                 private String text;

                 private Date messageTime;
             }

go client:

func main() {
err := config.Load()
if err != nil {
	fmt.Println(fmt.Sprintf("err:%v", err))
	logger.Errorf("init load config error:%v", err)
	os.Exit(-1)
}
time.Sleep(3e9)
textMessage := text.BaseTestRpcBO{}
textMessage.LigoLastMsg = new(text.LigoLastMsgInfo)
textMessage.LigoLastMsg.Text = "123123123"
textMessage.LigoLastMsg.MessageId = 23213
t := time.Now()
textMessage.ExtendContent = "123321"
textMessage.TestDateTime = &t
resp, errGet := model.TxtProvider.TestRpcApiV2(context.Background(), "vgroup test content", 11223344, textMessage)
if errGet != nil {
	logger.Errorf("response error:%v", errGet)
}
logger.Infof("resp:%v", resp)

}
go model:

func InitTestRpcBo() {
  // ------for hessian2------
  hessian.RegisterPOJO(&BaseTestRpcBO{})
  hessian.RegisterPOJO(&TestRpcBO{})
  hessian.RegisterPOJO(&SecondTestRpcBO{})
  hessian.RegisterPOJO(&LigoLastMsgInfo{})
}


type BaseTestRpcBO struct {
  LigoLastMsg   *LigoLastMsgInfo
  TextMap       map[string]string
  TextSet       []string
  ExtendId      int64
  ExtendContent string
  TestDateTime  *time.Time
}




 func (baseTestRpcbo BaseTestRpcBO) JavaClassName() string {
      return "xx.xx.xx.BaseTestRpcBO"
 }



type TestRpcBO struct {
  BaseTestRpcBO
  ExtendId      int64
  ExtendContent string
}



func (testRpcBo TestRpcBO) JavaClassName() string {
  return "xx.xx.xx.TestRpcBO"
}




 type SecondTestRpcBO struct {
  BaseTestRpcBO
  SecondId      int32
  SecondContent string
 }



func (secondTestRpcBo SecondTestRpcBO) JavaClassName() string {
return "xx.xx.xx.secondTestRpcBO"
}


type LigoLastMsgInfo struct {
  MessageId   int32
  Text        string
  MessageTime time.Time
}



 func (ligoLastMsgInfo LigoLastMsgInfo) JavaClassName() string {
    return "xx.xx.xx.LigoLastMsgInfo"
 }

provider:

      type ChatSystemApi struct {
  // dubbo标签,用于适配go侧客户端大写方法名 -> java侧小写方法名,只有 dubbo 协议客户端才需要使用
            SendMessage  func(ctx context.Context, from int64, message message.Message) (*CommResp, error)                                `dubbo:"sendMessage"`
            TestRpcApi   func(ctx context.Context, testContent string, testId int64, message message.Message) (*CommResp, error)          `dubbo:"testRpcApi"`
            TestRpcApiV2 func(ctx context.Context, testContent string, testId int64, baseTestRpcBO text.BaseTestRpcBO) (*CommResp, error) `dubbo:"testRpcApiV2"`

}

      var (
          TxtProvider *ChatSystemApi
      )

      func ProviderInit() {
          TxtProvider = &ChatSystemApi{}
          //	注册客户端存根类到框架,实例化客户端接口指针
          config.SetConsumerService(TxtProvider)
      }

      func (msg ChatSystemApi) JavaClassName() string {
          return "xx.xx.xx.ChatSystemApi"
      }

Anything else we need to know?:

@wongoo
Copy link
Contributor

wongoo commented Nov 26, 2021

@zhushengjun-it have u try the hessian2 v1.9.5?

@zhushengjun-it
Copy link
Author

@zhushengjun-it have u try the hessian2 v1.9.5?

upgrade hessian2 to v1.9.5, no change in results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants