PDA

View Full Version : Interfaces getting re-ordered on proxy creation



steven.warren
Feb 4th, 2005, 02:44 PM
version: 1.1.4

I have the following config snippet:



<bean name="view" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="singleton"><value>false</value></property>
<property name="proxyInterfaces">
<list>
<value>A</value>
<value>B</value>
</list>
</property>
<property name="interceptorNames">
<list>
<value>CAdvisor</value>
</list>
</property>
</bean>


(note the "B" interface extends the interface "C" for CAdvisor)

In my main code I get this bean and then call:



bean.setTargetSource&#40;targetSource&#41;;


Where targetSource is like a SingletonTargetSource containing a implementation of interface "A".

Sometimes (not always I think) when I instantiate a proxy the order of the interfaces returned (by calling proxy.getClass().getInterfaces()) is:

B
A
C

Not, A B C! I am not yet clear whether this is a defect in the JVM (1.4.2_07) or in the Class[] of interfaces passed in from JDKDynamicAOPProxy. Any thoughts or ideas on this?

Cheers
Steve

Update: this does not appear to be a jvm problem. A call to target.getProxiedInterfaces returns a class[] containing the target class first, followed by the interfaces B, A, C

steven.warren
Feb 4th, 2005, 05:08 PM
Ok, so I see the issue. In class "AdvisedSupport" all the advised interfaces are stored in a HashSet. This means that when the array of classes is created to send to proxy creation, the order of the interfaces is undefined.

This is a problem as the order of interfaces is significant to Proxy. I will file a JIRA regarding this, but am unclear as to whether folks think this is a defect or an enhancement request. I think it's a defect.

Update: filed under JIRA #SPR-688