[ 
https://issues.apache.org/jira/browse/TUSCANY-1930?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Verberne updated TUSCANY-1930:
-----------------------------------

    Attachment: TUSCANY-1930 (3) - CompositeWireBuilderImpl.java

I took a closer look at the code in method: 

      CompositeWireBuilderImpl.connectWires( ...)

The code 'joggles' with the following four variables:

ComponentReference   source, resolvedReference;
ComponentService         target, resolvedService;

The target and resolvedService variables point to the same logical concept but 
to different objects. The resolvedService object holds more information then 
the target object; i.e. the resolvedService object contains an 
interfaceContract whereas the target doesn't.  What's also different is value 
of the name attribute. The same applies to source and resolvedReference

Just by inspecting the code it seems that it contains two additional bugs. I 
have marked the places in the attached source code with:

// START FIX FOR POTENTIAL BUG (TUSCANY-1930)
// END FIX FOR POTENTIAL BUG (TUSCANY-1930)

Notice that these 'fixes' do not fix the bug reported in this bug report.

Taking a closer look at the code that fixed the bug reported in this bug report 
makes me wonder whether this fix is 'correct'. It does fix the problem but just 
by inspecting the code and knowing that the resolvedService object contains 
more information then the target object, it seems that the original code:

      resolvedReference.getTargets().add(resolvedService);

is better then my fix:

      resolvedReference.getTargets().add(target);

But if one does not apply my fix, the wire will cause a problem later on in the 
method:

CompositeWireBuilderImpl.createComponentReferenceTargets( ...)

The error is caused by the fact that the name attribute of the target object 
and resolvedService object are different. The target object seems to contain 
the correct name. But, as said earlier, it contains less information then the 
resolvedService object.

So it is also possible that the real bug is in the method: 
createComponentReferenceTargets( .. ) and that this method needs to be fixed.

> Wire specified in composite file not working
> --------------------------------------------
>
>                 Key: TUSCANY-1930
>                 URL: https://issues.apache.org/jira/browse/TUSCANY-1930
>             Project: Tuscany
>          Issue Type: Bug
>          Components: Java SCA Assembly Model
>    Affects Versions: Java-SCA-1.0, Java-SCA-1.0.1, Java-SCA-1.1
>         Environment: jre1.5.0_11 and jre1.6.0_03 
>            Reporter: Andy Verberne
>         Attachments: TUSCANY-1930 (3) - CompositeWireBuilderImpl.java
>
>
> When using a wire in my own composite file I got the error message and stack 
> trace as specified further down. 
> After debugging the source code of the SCA Assembly Model component I found 
> that this error can easily be reproduced by modifying the existing 
> integration test:
>     org.apache.tuscany.sca.itest.WireTestCase.java 
> This integration test does run successful but will fail when one makes the 
> following changes in the accompanying WireTest.composite file:
> Chnage:
>     <component name="WireService">
>       <implementation.java 
> class="org.apache.tuscany.sca.itest.WireServiceImpl"/>
>     </component>  
>       <wire source="WireClient/aWireService" 
> target="WireService/WireService"/>
> into:
>     <component name="WireServiceComponent">
>       <implementation.java 
> class="org.apache.tuscany.sca.itest.WireServiceImpl"/>
>     </component>  
>       <wire source="WireClient/aWireService" 
> target="WireServiceComponent/WireService"/>
> Notice the change of the component name. The bug in the code is such that the 
> wire will only work when the component and service name, specified in the 
> target of the wire (i.e. target="WireService/WireService) are equal. As is 
> the case in the current integration test. When the component name and service 
> name are different the wire will fail.
> I was able to fix the bug by modifying one line in the file: 
> org.apache.tuscany.sca.assembly.builder.impl.CompositeWireBuilderImpl.java
> I have attached this as a patch.
> I will also create a new issue in Jira proposing to modify the integration 
> test in order to detect this bug.
> However, I am not entirely sure whether this fix doesn't break other things. 
> The code preceding the line of of code I modified is rather suspicious:
>              // Resolve the target service
>             ComponentService target = wire.getTarget();
>             if (target != null && target.isUnresolved()) {
>                 resolvedService = componentServices.get(target.getName());
>                 if (resolvedService != null) {
>                     wire.setTarget(target);
> The last line doesn't really do anything useful. So maybe this code needs 
> refactoring ...
>  
> >>> Error message:
> 5-dec-2007 14:03:33 
> org.apache.tuscany.sca.assembly.builder.impl.CompositeBuilderImpl$1 problem
> WARNING: Component reference target not found, it might be a remote service: 
> WireService
> >>> Stack trace:
> org.osoa.sca.ServiceUnavailableException: No service invoker is available for 
> reference aWireService (bindingURI=null operation=sayHello).
>       at 
> org.apache.tuscany.sca.binding.sca.impl.RuntimeSCAReferenceBindingProvider.createInvoker(RuntimeSCAReferenceBindingProvider.java:192)
>       at 
> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.addBindingInterceptor(RuntimeWireImpl.java:214)
>       at 
> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.initInvocationChains(RuntimeWireImpl.java:156)
>       at 
> org.apache.tuscany.sca.core.assembly.RuntimeWireImpl.getInvocationChains(RuntimeWireImpl.java:97)
>       at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.getInvocationChain(JDKInvocationHandler.java:190)
>       at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:124)
>       at $Proxy7.sayHello(Unknown Source)
>       at 
> org.apache.tuscany.sca.itest.WireClientImpl.runTests(WireClientImpl.java:46)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>       at java.lang.reflect.Method.invoke(Unknown Source)
>       at 
> org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationInvoker.invoke(JavaImplementationInvoker.java:105)
>       at 
> org.apache.tuscany.sca.core.databinding.wire.PassByValueInterceptor.invoke(PassByValueInterceptor.java:49)
>       at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:233)
>       at 
> org.apache.tuscany.sca.core.invocation.JDKInvocationHandler.invoke(JDKInvocationHandler.java:130)
>       at $Proxy6.runTests(Unknown Source)
>       at 
> org.apache.tuscany.sca.itest.WireTestCase.testWire(WireTestCase.java:46)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>       at java.lang.reflect.Method.invoke(Unknown Source)
>       at junit.framework.TestCase.runTest(TestCase.java:164)
>       at junit.framework.TestCase.runBare(TestCase.java:130)
>       at junit.framework.TestResult$1.protect(TestResult.java:106)
>       at junit.framework.TestResult.runProtected(TestResult.java:124)
>       at junit.framework.TestResult.run(TestResult.java:109)
>       at junit.framework.TestCase.run(TestCase.java:120)
>       at junit.framework.TestSuite.runTest(TestSuite.java:230)
>       at junit.framework.TestSuite.run(TestSuite.java:225)
>       at 
> org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
>       at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to