You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Mike Edwards (JIRA)" <de...@tuscany.apache.org> on 2009/05/08 14:23:45 UTC

[jira] Created: (TUSCANY-3013) Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired

Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired
------------------------------------------------------------------------------------------------------------------

                 Key: TUSCANY-3013
                 URL: https://issues.apache.org/jira/browse/TUSCANY-3013
             Project: Tuscany
          Issue Type: Bug
          Components: Java SCA Core Runtime
    Affects Versions: Java-SCA-2.0
            Reporter: Mike Edwards
            Assignee: Mike Edwards
             Fix For: Java-SCA-2.0


If I have:
o a <component/> in a composite which uses a Java POJO as its implementation, 
o that POJO has a reference, which is declared with @Reference(required=false), so that the reference multiplicity is 0..1
o the <component/> leaves the <reference/> unwired (by any means)

the current code injects a Proxy into that reference - a Proxy that is unwired, and which causes an exception when invoked.

This is incorrect behaviour.  An unwired 0..1 reference should cause the injection of null into the reference in the POJO and the POJO should be able to test for this null at runtime and so avoid calling the reference.

The test which revealed this problem is the OASIS Assembly testcase ASM_12006_TestCase

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (TUSCANY-3013) Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired

Posted by "Mike Edwards (JIRA)" <de...@tuscany.apache.org>.
    [ https://issues.apache.org/jira/browse/TUSCANY-3013?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707796#action_12707796 ] 

Mike Edwards commented on TUSCANY-3013:
---------------------------------------

This problem is caused by code in 

org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java

and by the way that the "default binding", binding.sca is handled.

During processing of a reference, a refernce with no <binding/> subelements is given a default binding.sca for later wiring work.

However such a default binding has no attributes set (@uri and @name in particular).

IF the <reference/> is:
- not autowired
- unwired either be means of <wire/> elements or by means of content of the @target attribute
- and any <binding/> elements have no @uri value set

...then the code in ComponentReferenceEndpointReferenceBuilderImpl.java assumes that the target service(s) are defined by means of binding specific configuration (somewhere in the binding element itself)

For such cases, an endpoint is created as the target of the reference, but left unconfigured in the expectation that the binding will fill in the details later.

However, for a <binding.sca/> the only configuration IS the @uri attribute - if it is absent then the reference is UNWIRED - there is no target.  And of course, the default <binding.sca/> is precisely of this kind - no @uri.  So in the current code, an empty endpoint model is created, as if the details will be filled in from the binding later, but no such details ever get created.  The result at runtime is the invocation of a wire which goes nowhere - which causes a runtime exception.

The solution is to NOT create a wire for <binding.sca/> if there is no autowire, @target and no @uri.  This leaves the reference unwired, which may be a problem if it is a 1..x multiplicity reference, but is just fine if it is 0..x.

ONE TWIST - the same code also gets used for handling the pseudo-references for callbacks.  These pseudo references will not have a target identified - it is filled in later during the remainder of the callback processing.

> Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-3013
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-3013
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SCA Core Runtime
>    Affects Versions: Java-SCA-2.0
>            Reporter: Mike Edwards
>            Assignee: Mike Edwards
>             Fix For: Java-SCA-2.0
>
>
> If I have:
> o a <component/> in a composite which uses a Java POJO as its implementation, 
> o that POJO has a reference, which is declared with @Reference(required=false), so that the reference multiplicity is 0..1
> o the <component/> leaves the <reference/> unwired (by any means)
> the current code injects a Proxy into that reference - a Proxy that is unwired, and which causes an exception when invoked.
> This is incorrect behaviour.  An unwired 0..1 reference should cause the injection of null into the reference in the POJO and the POJO should be able to test for this null at runtime and so avoid calling the reference.
> The test which revealed this problem is the OASIS Assembly testcase ASM_12006_TestCase

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (TUSCANY-3013) Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired

Posted by "Mike Edwards (JIRA)" <de...@tuscany.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-3013?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Edwards resolved TUSCANY-3013.
-----------------------------------

    Resolution: Fixed

Resolved with the code committed in 

773349

- mainly with an update to ComponentReferenceEndpointReferenceBuilderImpl to check for non-Callback binding.sca references which have no autowire, targets or @uri.

> Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-3013
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-3013
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SCA Core Runtime
>    Affects Versions: Java-SCA-2.0
>            Reporter: Mike Edwards
>            Assignee: Mike Edwards
>             Fix For: Java-SCA-2.0
>
>
> If I have:
> o a <component/> in a composite which uses a Java POJO as its implementation, 
> o that POJO has a reference, which is declared with @Reference(required=false), so that the reference multiplicity is 0..1
> o the <component/> leaves the <reference/> unwired (by any means)
> the current code injects a Proxy into that reference - a Proxy that is unwired, and which causes an exception when invoked.
> This is incorrect behaviour.  An unwired 0..1 reference should cause the injection of null into the reference in the POJO and the POJO should be able to test for this null at runtime and so avoid calling the reference.
> The test which revealed this problem is the OASIS Assembly testcase ASM_12006_TestCase

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (TUSCANY-3013) Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired

Posted by "Mike Edwards (JIRA)" <de...@tuscany.apache.org>.
     [ https://issues.apache.org/jira/browse/TUSCANY-3013?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mike Edwards closed TUSCANY-3013.
---------------------------------


> Java POJO with reference marked as multiplicity 0..1 is given a reference proxy even when the reference is unwired
> ------------------------------------------------------------------------------------------------------------------
>
>                 Key: TUSCANY-3013
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-3013
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SCA Core Runtime
>    Affects Versions: Java-SCA-2.0
>            Reporter: Mike Edwards
>            Assignee: Mike Edwards
>             Fix For: Java-SCA-2.0
>
>
> If I have:
> o a <component/> in a composite which uses a Java POJO as its implementation, 
> o that POJO has a reference, which is declared with @Reference(required=false), so that the reference multiplicity is 0..1
> o the <component/> leaves the <reference/> unwired (by any means)
> the current code injects a Proxy into that reference - a Proxy that is unwired, and which causes an exception when invoked.
> This is incorrect behaviour.  An unwired 0..1 reference should cause the injection of null into the reference in the POJO and the POJO should be able to test for this null at runtime and so avoid calling the reference.
> The test which revealed this problem is the OASIS Assembly testcase ASM_12006_TestCase

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.