You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/10/22 03:42:47 UTC

[GitHub] [dubbo-go-hessian2] shenchao861129 opened a new issue, #325: 对Java枚举类型可变长参数方法的支待完善

shenchao861129 opened a new issue, #325:
URL: https://github.com/apache/dubbo-go-hessian2/issues/325

   我正在做一份重构工作,使用go重构原有的java服务,dubbo版本2.5.4、dubbgo-go版本3.0.1,使用hessian2协议。
   正常情况,dubbo-go-hessian2对java枚举类型支持的很好,但是我们遇到要重构的Java方法中出现枚举类型可变长参数时,就出现问题了。
   ![image](https://user-images.githubusercontent.com/834323/197317360-a77b1726-df4d-42ae-b684-7ad89cf10024.png)
   ![image](https://user-images.githubusercontent.com/834323/197317397-1aeb251b-2501-42a7-b31a-e7f30ba841a6.png)
   比如上图中的getBooksByStatuses1、getBooksByStatuses2两个方法。前者在Go服务中的实现可以正常工作,但是后者被调用后就会报错。
   ![image](https://user-images.githubusercontent.com/834323/197317445-a4bbcb0d-a60e-4d56-b4e7-e0b733b3f2ad.png)
   通过调试发现问题出在github.com/apache/dubbo-go-hessian2@v1.11.1/list.go:382行。进一步调试后发现aryValue是[]*BookStatusTypeEnum类型,而EnsureRawValue(it)方法的返回值是hessian.JavaEnum类型,类型不匹配,所以在赋值时这里就panic了。
   目前想到一个解决方案,在这里介绍下,请大佬看看这么改是否合理。
   将接参的变量类型改为[]interface{},这样就可以解决当前的问题。
   可以通过getListType方法来实现,在里面增加一个判断,如果当前是枚举类型,那么就直接返回nil,这样会生成一个interface{}类型的切片。
   ![image](https://user-images.githubusercontent.com/834323/197317605-6c5d2c5d-6a47-45a1-bcf6-bf2b4c923175.png)
   
   ![image](https://user-images.githubusercontent.com/834323/197317574-d0c109d6-6871-4eb6-a4f8-1a1292c1445d.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go-hessian2] wongoo closed issue #325: 完善对Java枚举类型可变长参数方法的支持

Posted by GitBox <gi...@apache.org>.
wongoo closed issue #325: 完善对Java枚举类型可变长参数方法的支持
URL: https://github.com/apache/dubbo-go-hessian2/issues/325


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org