wrong behavior of InstanceManager.onSet(..) method
--------------------------------------------------
Key: FELIX-2603
URL: https://issues.apache.org/jira/browse/FELIX-2603
Project: Felix
Issue Type: Bug
Components: iPOJO
Affects Versions: iPOJO-1.4.0
Environment: all
Reporter: P.A
Hello,
Clement and I has talked about this issue, and some different point of views
are welcome.
Currently, in the InstanceManager.onSet(..) method, the calls to the
FieldInterceptor.onSet(..) is conditioned by '!value.equals(objectValue)', the
'value' is the current reference to the intercepted field, 'objectValue' is the
reference that is going to be assigned to the intercepted field.
See line 1096 of InstanceManager.java in iPOJO core 1.6.4.
Thus, in my opinion, the semantic of 'onSet' is not really what is described in
the iPOJO documentation "This method is called each time a field of the POJO is
assigned" (see
http://felix.apache.org/site/how-to-write-your-own-handler.html#Howtowriteyourownhandler-InteractingwiththePOJO).
Its semantic is rather "this method is called each time a field of the POJO is
assigned and the new assigned value is different (in the 'equals(..)' method
way) from the current value".
Moreover, the call to 'equals' method can result in some expensive
computations, thus this optimization can be counter productive.
I suggest to remove the condition '!value.equals(objectValue))' in
'InstanceManager.onSet(..)'.
If some external codes rely on the current behavior of onSet(..), rename the
'InstanceManager.onSet(..)' to 'InstanceManager.onModification(..)', add the
method onModification(..) in FieldInterceptor interface, and adapt the external
codes to use this new 'onModification(..)' method.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.