Niels Bertram created ARIES-1282:
------------------------------------
Summary: BeanRecipe.findMatchingMethods is not able to filter out
overridden method signatures
Key: ARIES-1282
URL: https://issues.apache.org/jira/browse/ARIES-1282
Project: Aries
Issue Type: Bug
Components: Blueprint
Affects Versions: blueprint-core-1.1.0, blueprint-core-1.4.2
Reporter: Niels Bertram
I was trying to get an Infinispan cache object from an infinispan CacheManager
using the following blueprint configuration:
{code:xml}
<reference id="cacheManager" availability="mandatory"
interface="org.infinispan.manager.CacheContainer" />
<bean id="queueCountCache" factory-ref="cacheManager" factory-method="getCache">
<argument index="0" type="java.lang.String" value="QueueCountCache" />
</bean>
{code}
Unfortunately the blueprint startup fails with following error:
{code}
org.osgi.service.blueprint.container.ComponentDefinitionException: Multiple
matching factory methods getCache found on class
Proxy36341b52_07db_4c05_bab0_40dbf8a3899a for arguments [QueueCountCache] when
instanciating bean queueCountCache: [public
org.infinispan.commons.api.BasicCache
Proxy36341b52_07db_4c05_bab0_40dbf8a3899a.getCache(java.lang.String), public
org.infinispan.Cache
Proxy36341b52_07db_4c05_bab0_40dbf8a3899a.getCache(java.lang.String)]
at
org.apache.aries.blueprint.container.BeanRecipe.getInstance(BeanRecipe.java:305)[7:org.apache.aries.blueprint.core:1.4.0]
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:806)[7:org.apache.aries.blueprint.core:1.4.0]
at
org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:787)[7:org.apache.aries.blueprint.core:1.4.0]
...
{code}
looking at the matches produced by the {{BeanRecipe.findMatchingMethods}} makes
it obvious that the {{CacheContainer}} implements an interface
{{BasicCacheContainer}}. The {{CacheContainer}} interface overrides the
getCache(java.lang.String) that is initially defined in the
{{BasicCacheContainer}} without any changes. I guess this was implemented for
some backward compatibility.
The {{BeanRecipe.findMatchingMethods}} probably also needs to check if the
method signatures found are overridden by another method in the matching
collection. If that is the case, all methods that are overridden also need to
be discharged.
Here are the 2 offending interfaces that the {{BeanReceipe}} matchtes:
{code:title=CacheContainer.java|borderStyle=solid}
package org.infinispan.manager;
import org.infinispan.Cache;
import org.infinispan.commons.api.BasicCache;
import org.infinispan.commons.api.BasicCacheContainer;
public interface CacheContainer extends BasicCacheContainer {
@Override
<K, V> Cache<K, V> getCache();
@Override
<K, V> Cache<K, V> getCache(String cacheName);
}
{code}
{code:title=BasicCacheContainer.java|borderStyle=solid}
package org.infinispan.commons.api;
public interface BasicCacheContainer extends Lifecycle {
<K, V> BasicCache<K, V> getCache();
<K, V> BasicCache<K, V> getCache(String cacheName);
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)