[arquillian-issues] [JBoss JIRA] (ARQ-1976) All ResourceProvider#canProvide implementations could try to inject subtypes

Richard Achmatowicz (JIRA) issues at jboss.org
Tue Sep 1 12:08:05 EDT 2015


    [ https://issues.jboss.org/browse/ARQ-1976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13104183#comment-13104183 ] 

Richard Achmatowicz commented on ARQ-1976:
------------------------------------------

This issue and its PR were observed when testing https://issues.jboss.org/browse/WFLY-4255.
Certain test cases were not passing with the exception:

{noformat}
Running org.jboss.as.test.clustering.xsite.XSiteSimpleTestCase
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.043 sec <<< FAILURE! - in org.jboss.as.test.clustering.xsite.XSiteSimpleTestCase
testPutRelayedToBackups(org.jboss.as.test.clustering.xsite.XSiteSimpleTestCase) Time elapsed: 0.033 sec  <<< ERROR!
java.lang.RuntimeException: Could not set value on field protected org.jboss.as.arquillian.api.WildFlyContainerController org.jboss.as.test.clustering.cluster.ClusterAbstractTestCase.controller using org.jboss.arquillian.container.test.impl.client.container.ClientContainerController at 19b89d4, exception = Can not set org.jboss.as.arquillian.api.WildFlyContainerController field org.jboss.as.test.clustering.cluster.ClusterAbstractTestCase.controller to org.jboss.arquillian.container.test.impl.client.container.ClientContainerController
    at org.jboss.arquillian.test.impl.enricher.resource.ArquillianResourceTestEnricher.enrich(ArquillianResourceTestEnricher.java:103)
    at org.jboss.arquillian.test.impl.TestInstanceEnricher.enrich(TestInstanceEnricher.java:52)
    at org.jboss.arquillian.container.test.impl.ClientTestInstanceEnricher.enrich(ClientTestInstanceEnricher.java:51)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
    at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
    at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createContext(ContainerEventController.java:142)
    at org.jboss.arquillian.container.test.impl.client.ContainerEventController.createBeforeContext(ContainerEventController.java:124)
{noformat}

which in turn was caused by the wrong ResourceProvider being picked up and used to inject the resource.

With the fix of this issue, that problem goes away.

> All ResourceProvider#canProvide implementations could try to inject subtypes
> ----------------------------------------------------------------------------
>
>                 Key: ARQ-1976
>                 URL: https://issues.jboss.org/browse/ARQ-1976
>             Project: Arquillian
>          Issue Type: Bug
>            Reporter: Radoslav Husar
>
> Currently the conditions seem to be the other way round as they normally would:
> {noformat}
>     @Override
>     public boolean canProvide(Class<?> type)
>     {
> -      return Deployer.class.isAssignableFrom(type);
> +      return type.isAssignableFrom(Deployer.class);
>     }
> {noformat}
> It does not seem to be intentional. This would not be usually spotted because usually the same class is injected and requested and no provider provides a subtype of other ResourceProvider, so the problem would never occur.
> The resulting exception would look like:
> {noformat}
> java.lang.RuntimeException: Could not set value on field protected ClassA TestClass.field using ClassB at 19b89d4, 
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


More information about the arquillian-issues mailing list