H1. symptom
Added a method for a dubbbo interface:
{Code} domainobject <string> testser (); Implementation: @ override public domainobject <string> testser () {domainobject <string> result = new domainobject <string> (); result. setage (10); result. setname ("test"); result. add ("domainobject1"); return result ;}{ code}
The return value is defined as follows:
{code}public class DomainObject<E> extends ArrayList<E> { private static final long serialVersionUID = -7393642276493435828L; private String name; private int age;}{code}
Remote Call:
{code}DomainObject<String> result = voucherInfoQueryService.testSer();System.out.println(result.getAge());System.out.println(result.getName());System.out.println(result.get(0));{code}
Output result: the values of the age and name attributes are lost, while the values in the list still exist.
{code}0nullDomainObject1{code}H1. troubleshooting h4. use Java built-in serialization to execute serialization and deserialization, and the attribute will not be lost. It is suspected that Dubbo serialization has special processing. The default serialization protocol used by h4. Dubbo is hessian2. view the code
The serialization time code is as follows:
{Code} public void writeobject (Object object) throws ioexception {If (Object = NULL) {writenull (); return;} serializer; # Find the corresponding serializer = findserializerfactory (). getserializer (object. getclass (); # serialize serializer. writeobject (object, this) ;}{ code}
Search for serializer: The Code shows that the serializer corresponding to the above domainobject is collectionserializer.
{code}public Serializer getSerializer(Class cl) throws HessianProtocolException { ... else if (Collection.class.isAssignableFrom(cl)) { if (_collectionSerializer == null) {_collectionSerializer = new CollectionSerializer(); ... }{code}
Collectionserializer. writeobject
{code}public void writeObject(Object obj, AbstractHessianOutput out) throws IOException { ... Iterator iter = list.iterator(); while (iter.hasNext()) { Object value = iter.next(); out.writeObject(value); } ... }{code}
Therefore, attributes are lost.