eclipse-ee4j / orb

Eclipse ORB is a CORBA orb for use in Jakarta EE and GlassFish and other projects that still need an ORB.

Home Page:https://projects.eclipse.org/projects/ee4j.orb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`putFields` field gets overwritten for every field

pzygielo opened this issue · comments

@Override
public ObjectOutputStream.PutField putFields()
throws IOException {
putFields = new HookPutFields();
return putFields;
}

Thus - if class defines few fields AND in its writeObject methods registers each one with separate outStream.putFields().put(...) - like ConcurrentHashMap (JDK8) does:
https://github.com/openjdk/jdk/blob/9a9add8825a040565051a09010b29b099c2e7d49/jdk/src/share/classes/java/util/concurrent/ConcurrentHashMap.java#L1403-L1405
then only one field is serialized with value, and the remaining are serialized as nulls in (example for int):

case 'I':
if (value == null) {
orbStream.write_long(0);
} else {
orbStream.write_long(((Integer) value).intValue());
}
break;

But due to putFields being overwritten - fields at

Object value = fields.get(osfields[i].getName());

is new, one-element only map, for every new field put to the stream.