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 2021/03/12 06:35:02 UTC

[GitHub] [dubbo-go-hessian2] Euraxluo opened a new issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Euraxluo opened a new issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262


   <!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks!
   
   -->
   
   
   **What happened**:
   go-mod:
   ```
   require (
   	github.com/apache/dubbo-go v1.5.5
   	github.com/apache/dubbo-go-hessian2 v1.8.2
   	github.com/dubbogo/gost v1.9.5
   )
   ```
   当我使用以上版本进行和java dubbo进行通信时,发现复杂嵌套对象的序列化会出错,会把List<UserVo>序列化为List<HashMap>,导致服务端代码运行失败
   
   **What you expected to happen**:
   错误的序列化,导致实体类中的某些方法无法被调用
   
   
   **How to reproduce it (as minimally and precisely as possible)**:
   server
   ```java
   //interface
   public interface UserProvider {
       void collectionUser(Page<UserVo> pageUserVo);
   }
   //impl
   public class UserProviderImpl implements UserProvider {
       public void collectionUser(Page<UserVo> pageUserVo ){
           List<UserVo> userVoList =  pageUserVo.getData();
           UserVo userVo = (UserVo) userVoList.toArray()[0];
           return;
       }
   }
   
   //pojo Page
   public class Page<T> implements Serializable {
       private static final long serialVersionUID = 1L;
       private List<T> data;
   
       public Page() {
       }
       public Page( List<T> data) {
           this.data = data;
       }
       public List<T> getData() {
           return this.data;
       }
   
       public void setData(List<T> data) {
           this.data = data;
       }
   }
   //pojo UserVo
   public class UserVo implements Serializable {
       private User user;
       public UserVo(User user) { this.user = user; }
       public UserVo() { }
       public User getUser() {
           return user;
       }
       public void setUser(User user) {
           this.user = user;
       }
   }
   ```
   client_main.go
   ```go
   var (
   	appName         = "UserProviderGer"
   	referenceConfig = config.ReferenceConfig{
   		Registry:      "demoZk",
   		InterfaceName: "com.dml_express.dubbo_test.UserProvider",
   		Cluster:       "failover",
   		Protocol:      dubbo.DUBBO,
   		Generic:       true,
   	}
   )
   
   func init() {
   	hessian.RegisterPOJO(&pkg.User{})
   	hessian.RegisterPOJO(&pkg.UserVo{})
   	hessian.RegisterPOJO(&pkg.UserVos{})
   	referenceConfig.GenericLoad(appName)
   }
   func main() {
   collectionUser()
   }
   func collectionUser() {
   	genericService := referenceConfig.GetRPCService().(*config.GenericService)
   	page :=pkg.Page{
   		Data: []pkg.UserVo{
   			pkg.UserVo{
   				User: pkg.User{
   					Id:   "1000",
   					Name: "user_name",
   					Age:  2,
   					Time: time.Now(),
   				},
   			},
   			pkg.UserVo{
   				User: pkg.User{
   					Id:   "1000",
   					Name: "user_name",
   					Age:  2,
   					Time: time.Now(),
   				},
   			},
   		},
   	}
   	resp, err := genericService.Invoke(context.TODO(),
   		[]interface{}{"collectionUser",
   			[]string{"com.dml_express.dubbo_test.Page"},
   			[]interface{}{page}})
   
   	if err != nil {
   		gxlog.CError("error: %v\n", err)
   		os.Exit(1)
   		return
   	}
   	gxlog.CInfo("response result: %v\n", resp)
   }
   
   ```
   pkg.user.go
   ```go
   type User struct {
   	Id   string
   	Name string
   	Age  int32
   	Time time.Time
   }
   func (User) JavaClassName() string {
   	return "com.dml_express.dubbo_test.User"
   }
   type UserVo struct{
   	User  User
   }
   func (UserVo) JavaClassName() string {
   	return "com.dml_express.dubbo_test.UserVo"
   }
   
   type Page struct {
   	Data []UserVo `hessian:"data"`
   }
   func (Page) JavaClassName() string {
   	return "com.dml_express.dubbo_test.Page"
   }
   ```
   **Anything else we need to know?**:
   当我调用时,会报以下错误在java端impl中
   ` error: java.lang.ClassCastException: java.util.HashMap cannot be cast to com.dml_express.dubbo_test.UserVo
   `
   
   一些其他的图片:
   go调用java
   ![image-20210312142331445](https://gitee.com/Euraxluo/images/raw/master/picgo/image-20210312142331445.png)
   
   java互相调用:
   ![image-20210312143218876](https://gitee.com/Euraxluo/images/raw/master/picgo/image-20210312143218876.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.

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] woostundy commented on issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
woostundy commented on issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262#issuecomment-870416269


   I met this problem too. Are there any least updates?


-- 
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


[GitHub] [dubbo-go-hessian2] wongoo commented on issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
wongoo commented on issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262#issuecomment-797279718


   @Euraxluo pls create a unit test for this issue, u can ref the following example:
   
   eg: 
   - https://github.com/apache/dubbo-go-hessian2/blob/cbcfbc21675e5f81e31d1257f333e8b0c384d463/test_hessian/src/main/java/test/TestCustomReply.java#L524
   - https://github.com/apache/dubbo-go-hessian2/blob/cbcfbc21675e5f81e31d1257f333e8b0c384d463/object_test.go#L801


----------------------------------------------------------------
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.

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 #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
wongoo closed issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262


   


-- 
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


[GitHub] [dubbo-go-hessian2] wongoo closed issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
wongoo closed issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262


   


-- 
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


[GitHub] [dubbo-go-hessian2] sanxun0325 commented on issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
sanxun0325 commented on issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262#issuecomment-974624596


   You are advised to upgrade hessian. No problem is found when the latest version is used
   ![image](https://user-images.githubusercontent.com/28588342/142721912-0e257665-10d9-4ebd-a320-96eaf7ca4578.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

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] sanxun0325 commented on issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
sanxun0325 commented on issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262#issuecomment-974624596


   You are advised to upgrade hessian. No problem is found when the latest version is used
   ![image](https://user-images.githubusercontent.com/28588342/142721912-0e257665-10d9-4ebd-a320-96eaf7ca4578.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

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 edited a comment on issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
wongoo edited a comment on issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262#issuecomment-797279718


   @Euraxluo pls create a unit test for this issue, u can ref the following example, the submit it as a PR:
   
   eg: 
   - https://github.com/apache/dubbo-go-hessian2/blob/cbcfbc21675e5f81e31d1257f333e8b0c384d463/test_hessian/src/main/java/test/TestCustomReply.java#L524
   - https://github.com/apache/dubbo-go-hessian2/blob/cbcfbc21675e5f81e31d1257f333e8b0c384d463/object_test.go#L801


----------------------------------------------------------------
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.

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 edited a comment on issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
wongoo edited a comment on issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262#issuecomment-797279718


   @Euraxluo pls create a unit test for this issue, u can ref the following example, then submit it as a PR:
   
   eg: 
   - https://github.com/apache/dubbo-go-hessian2/blob/cbcfbc21675e5f81e31d1257f333e8b0c384d463/test_hessian/src/main/java/test/TestCustomReply.java#L524
   - https://github.com/apache/dubbo-go-hessian2/blob/cbcfbc21675e5f81e31d1257f333e8b0c384d463/object_test.go#L801


----------------------------------------------------------------
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.

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] woostundy commented on issue #262: 形如Page{List data;},T=UserVo, UserVo{User user;}的多层嵌套结构,在序列化时,UserVo被序列化为HashMap

Posted by GitBox <gi...@apache.org>.
woostundy commented on issue #262:
URL: https://github.com/apache/dubbo-go-hessian2/issues/262#issuecomment-870416269


   I met this problem too. Are there any least updates?


-- 
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