edoclin commented on issue #15750:
URL: https://github.com/apache/dubbo/issues/15750#issuecomment-3488774277
> You might encounter other trouble if you set
`-Dcom.caucho.hessian.unsafe=false` since there are many deserializations of
dubbo hessian lite depend on it. maybe your provider should be refactored like
this:
>
> ```
> public class MsgGetReq implements Serializable {
> private short type;
> private short appId;
> public MsgGetReq() {
> type = 1;
> }
> }
> ```
@zrlw
In `UnsafeDeserializer` , the method
`com.alibaba.com.caucho.hessian.io.UnsafeDeserializer#instantiate` bypasses the
constructor and directly “raw-allocates” object instances, so default values
cannot be initialized via the constructor.
`com.alibaba.com.caucho.hessian.io.UnsafeDeserializer#getReadResolve`
provides a `readResolve` hook; I have to implement it in order to initialize
default values:
```java
public class MsgGetReq implements
Serializable {
private short type;
private short appId;
public MsgGetReq readResolve() {
type = 1;
return this;
}
}
```
However, after upgrading to Dubbo 3, there may be many such cases in the
existing codebase, and we must find them and add `readResolve` methods.
Is there a better compatibility approach when using UnsafeDeserializer ?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]