We have got a very hard bug. The equals
- Method in our domain object DomainOrder
was implemented wrong. The problem is, that the domain object is used by our clients incl. all old versions. So the clients must be updated too.
Clients communicate with server over RMI (JEE-6)
We have to fix it as soon as possible, but there are too many clients. So our idea was to fix the issue temporarily on the server side. But I'm not sure it would work.
current situation, our result Set
contains just one object, cause equals
returns true
for different object:
[...]
List<DBOrder> list = orderService.getOrders(criteria);
Set<DomainOrder> orders = new HashSet<>();
for(DBOrder dborder : list){
orders.add(convertDBOrderToDomain(dborder)); // mapping new DomainOrder(..)
}
[...]
How would I fix it on server side:
List<DBOrder> list = orderService.getOrders(criteria);
Set<DomainOrder> orders = new HashSet<>();
for(DBOrder dborder : list){
final DomainOrder domainOrder = convertDBOrderToDomain(dborder);
// temp fix for all old versions.
orders.add(new DomainOrder(){
private DomainOrder delegate = domainOrder ;
@Override
public Long getId(){
return delegate.getId();
}
[...]
@Override
public boolean equals(){
return [fix];
}
});
}
So what do you think will it work? The iImportant goals are:
I hope some own with experience in java serialisation and RMI can help me.
The important goals are:
- The client will get all Orders
That's simply a matter of how you reimplement equals()
.
- The client will get NO error on deserialization of result.
That requires that you don't change the serialVersionUID
of the class concerned. If it doesn't have one, get it from the serialver
tool before you change it.