From 9b64185ceb87c40028c01c38a2da81a165076e81 Mon Sep 17 00:00:00 2001 From: rfeng Date: Mon, 8 Feb 2010 21:37:54 +0000 Subject: Use a dummy invocation chain to avoid NPE on ConcurrentHashMap git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@907812 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java index d737b839ba..733880a9b3 100644 --- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java +++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java @@ -200,6 +200,11 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint 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 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint 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; } } -- cgit v1.2.3