Details
-
Type: Improvement
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 1.2-RC2
-
Fix Version/s: 1.2
-
Component/s: PicoContainer (Java)
-
Labels:None
-
Number of attachments :
Description
CachingComponentAdapter calls ObjectReference.get() twice when getting the component. The object reference may be expensive to create (thus it is cached).
if (instanceReference.get() == null)
{ Object instance = super.getComponentInstance(container); instanceReference.set(instance); }return instanceReference.get()
I also have had a problem with the second get() when using a 'NULL' cache (object reference that does not cache the value at all).
I would like to change the above code to:
Object instance = instanceReference.get();
if (instance == null)
return instance;
Thanks,
John.
Activity
Jörg Schaible
made changes -
Field | Original Value | New Value |
---|---|---|
Resolution | Fixed [ 1 ] | |
Fix Version/s | 1.2 [ 11330 ] | |
Assignee | Joerg Schaible [ joehni ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Well, the idea is the ObjectReference to be the cache, so it should not be expensive to get the instance. And for the NullObjectReference ... why do you then use the CachingCA at all? ==> Continue discussion at the list please.
Nevertheless, I've changed the code to call get() only once. Thanks for heads-up.