You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2010/02/08 22:37:54 UTC
svn commit: r907812 -
/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
Author: rfeng
Date: Mon Feb 8 21:37:54 2010
New Revision: 907812
URL: http://svn.apache.org/viewvc?rev=907812&view=rev
Log:
Use a dummy invocation chain to avoid NPE on ConcurrentHashMap
Modified:
tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java?rev=907812&r1=907811&r2=907812&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java Mon Feb 8 21:37:54 2010
@@ -200,6 +200,11 @@
return bindingInvocationChain;
}
+ /**
+ * A dummy invocation chain representing null as ConcurrentHashMap doesn't allow null values
+ */
+ private static final InvocationChain NULL_CHAIN = new InvocationChainImpl(null, null, false, null);
+
public InvocationChain getInvocationChain(Operation operation) {
InvocationChain cached = invocationChainMap.get(operation);
if (cached == null) {
@@ -211,9 +216,13 @@
return chain;
}
}
- invocationChainMap.put(operation, null);
+ // Cache it with the NULL_CHAIN to avoid NPE
+ invocationChainMap.put(operation, NULL_CHAIN);
return null;
} else {
+ if (cached == NULL_CHAIN) {
+ cached = null;
+ }
return cached;
}
}