Description
Both PersistentField implementations that use JavaBeans compliant calls (PersistentFieldIntrospectorImpl and PersistentFieldCGLibImpl) fail if nested object reference was modified by its setter method.
Both classes implement PersistentField.set(Object, Object) in a similar way. Problem arises because internally in this method the reference to a nested object (see "attribute" local variable) will be held and used after actual setter method was called and thus performing further steps (like setting rest in "propertyGraph") on potentially "old" (wrong) reference.
This Problem is reproducible by introducing a clone() method for NestedEntry in org.apache.ojb.broker.metadata.PersistentFieldTest and altering NestedMain's setNestedEntry(NestedEntry) by setting private "nestedEntry" with a clone instead of actual method parameter:
this.nestedEntryXXX = (NestedEntry) nestedEntry.clone();
After performing those changes on PersistentFieldTest following two use-cases fail:
- testIntrospector() and
- testAutoProxy() (since PersistentFieldCGLibImpl is used in that use-case).