summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-01-29 22:30:05 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-01-29 22:30:05 +0000
commiteb644871fca453fbc7de6dc6746eade97cb3a848 (patch)
tree82bf9d160dac558ff8bce443b7515d588709d798 /sca-java-2.x/trunk/modules
parenta148d775bbddbf66c45074626319ca108b23a938 (diff)
Defer the initialization of the chains at later stage to make sure the endpoint reference won't be left in a wrong state if any exception happens
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@904649 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
index 2f18084890..57ca960c5b 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
@@ -248,7 +248,6 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
* Initialize the invocation chains
*/
private void initInvocationChains() {
- chains = new ArrayList<InvocationChain>();
InterfaceContract sourceContract = getComponentTypeReferenceInterfaceContract();
// TODO - EPR why is this looking at the component types. The endpoint reference should have the right interface contract by this time
//InterfaceContract sourceContract = getLeafInterfaceContract(endpointReference);
@@ -268,7 +267,8 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
throw new IllegalStateException(e);
}
}
-
+
+ List<InvocationChain> chainList = new ArrayList<InvocationChain>();
RuntimeComponentReference reference = (RuntimeComponentReference)getReference();
for (Operation operation : sourceContract.getInterface().getOperations()) {
Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
@@ -283,10 +283,13 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
if (operation.isNonBlocking()) {
addNonBlockingInterceptor(chain);
}
- chains.add(chain);
+ chainList.add(chain);
addReferenceBindingInterceptor(chain, operation);
}
+ // Set the chains until it's fully populated. If we initialize too early, any exeception could
+ // leave this endpoint reference in a wrong state with an empty chain.
+ chains = chainList;
wireProcessor.process(this);
}