deki closed pull request #461: [CXF-7832]WrappedMessageContext containsKey not 
consistent with get/put
URL: https://github.com/apache/cxf/pull/461
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
 
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
index 85a28e04e26..d635ab8ece7 100644
--- 
a/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
+++ 
b/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/context/WrappedMessageContext.java
@@ -193,7 +193,8 @@ public void clear() {
     }
 
     public final boolean containsKey(Object key) {
-        return message.containsKey(mapKey((String)key));
+        return message.containsKey(mapKey((String)key))
+            || get(key) != null;
     }
 
     public final boolean containsValue(Object value) {
diff --git 
a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedMessageContextTest.java
 
b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedMessageContextTest.java
index 674791d3c05..2e5c557f8cb 100644
--- 
a/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedMessageContextTest.java
+++ 
b/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/context/WrappedMessageContextTest.java
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxws.context;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -81,4 +82,18 @@ public void testPutAndGetJaxwsAttachments() throws Exception 
{
             }
         }
     }
+    
+    
+    @Test
+    public void testContainsKey() throws Exception {
+        WrappedMessageContext context =
+            new WrappedMessageContext(new HashMap<String, Object>(), null, 
Scope.APPLICATION);
+
+        Map<String, List<String>> headers = new HashMap<>();
+        context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
+
+        assertNotNull(context.get(MessageContext.HTTP_REQUEST_HEADERS));
+
+        assertTrue(context.containsKey(MessageContext.HTTP_REQUEST_HEADERS));
+    }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to