apache / dubbo

The java implementation of Apache Dubbo. An RPC and microservice framework.
https://dubbo.apache.org/
Apache License 2.0
40.48k stars 26.43k forks source link

Enum Deserializer question; #5387

Closed Kimi909 closed 4 years ago

Kimi909 commented 4 years ago

example: one enum class in service A :

public enum A {

    name(1,"1"),
    age(2,"2");
}

service B Already started ,one consumer call service A but enum A has changed :

public enum A {

    name(1,"1"),
    age(2,"2"),
    area(3,"3");
}

in this case,service B will report error java.lang.IllegalArgumentException: No enum constant com.XXX.enums.A.area , It is ok if restart;but whether there’s Better solution?

lkj41110 commented 4 years ago

new consumer ->old provider has this error.you can limit new consumer ->new provider using group or version

Kimi909 commented 4 years ago

new consumer ->old provider has this error.you can limit new consumer ->new provider using group or version

Actual situation of the project that the provider is another team, we don't know about the updates already deployed ,our container online service still old ; you means that the enum class add version ?

lkj41110 commented 4 years ago

Provider must be sent first in most scenes. multi-versions can distinguish between different versions,But its premise is that the provider is able http://dubbo.apache.org/zh-cn/docs/user/demos/multi-versions.html

Kimi909 commented 4 years ago

yes , we didn't specified version ;so I think it's not recommended that the entity class in the interface contains enum attribute , Maybe this will solve the problem.

chickenlj commented 4 years ago

It's a restriction of the Hessian2 serialization protocol. Please consider other serialization protocol supported by dubbo