You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@aries.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2018/01/31 08:19:00 UTC

[jira] [Commented] (ARIES-1282) BeanRecipe.findMatchingMethods is not able to filter out overridden method signatures

    [ https://issues.apache.org/jira/browse/ARIES-1282?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16346410#comment-16346410 ] 

ASF subversion and git services commented on ARIES-1282:
--------------------------------------------------------

Commit 1822771 from [~gnt] in branch 'aries/trunk'
[ https://svn.apache.org/r1822771 ]

[ARIES-1282] BeanRecipe.findMatchingMethods is not able to filter out overridden method signatures

> 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
>            Priority: Major
>             Fix For: blueprint-core-1.9.0
>
>
> 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.
> {code}
> public org.infinispan.commons.api.BasicCache Proxy6e18b006_c93d_4840_bb4d_3522802f6a68.getCache(java.lang.String)=[QueueCountCache]
> {code}
> and
> {code}
> public org.infinispan.Cache                  Proxy6e18b006_c93d_4840_bb4d_3522802f6a68.getCache(java.lang.String)=[QueueCountCache]
> {code}
> 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}} matches. Unfortunately the CacheContainer getCache method is the one it should match but +not+ the one from BasicCacheContainer.
> {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
(v7.6.3#76005)