Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
iPOJO-1.4.0
-
None
-
all
Description
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.