summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core/src/main
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-11 06:49:05 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2008-08-11 06:49:05 +0000
commit882c37efdbbb751bfa7a074f19e5e98debd56abd (patch)
treee8084fd7675395386210a46924be431c42ecaef9 /java/sca/modules/core/src/main
parent1bcfd44d79aff347c08809a5555171cd490d6431 (diff)
Protect against NPE when InterfaceContract is null
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@684647 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/core/src/main')
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextImpl.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextImpl.java
index 33de9f34bb..ed01a509d2 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextImpl.java
@@ -219,7 +219,11 @@ public class ComponentContextImpl implements RuntimeComponentContext {
InterfaceContract refInterfaceContract = getInterfaceContract(interfaceContract, businessInterface);
if (refInterfaceContract != interfaceContract) {
ref = (RuntimeComponentReference)reference.clone();
- ref.setInterfaceContract(interfaceContract);
+ if (interfaceContract != null) {
+ ref.setInterfaceContract(interfaceContract);
+ } else {
+ ref.setInterfaceContract(refInterfaceContract);
+ }
}
ref.setComponent(component);
return new ServiceReferenceImpl<B>(businessInterface, component, ref, binding, proxyFactory, compositeActivator);
@@ -342,14 +346,17 @@ public class ComponentContextImpl implements RuntimeComponentContext {
*/
private InterfaceContract getInterfaceContract(InterfaceContract interfaceContract, Class<?> businessInterface)
throws CloneNotSupportedException, InvalidInterfaceException {
- Interface interfaze = interfaceContract.getInterface();
boolean compatible = false;
- if (interfaze instanceof JavaInterface) {
- Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
- if (businessInterface.isAssignableFrom(cls)) {
- compatible = true;
+ if (interfaceContract != null && interfaceContract.getInterface() != null) {
+ Interface interfaze = interfaceContract.getInterface();
+ if (interfaze instanceof JavaInterface) {
+ Class<?> cls = ((JavaInterface)interfaze).getJavaClass();
+ if (businessInterface.isAssignableFrom(cls)) {
+ compatible = true;
+ }
}
}
+
if (!compatible) {
// The interface is not assignable from the interface contract
interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();