cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1476168 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/fr...
Date Fri, 26 Apr 2013 12:25:31 GMT
Author: sergeyb
Date: Fri Apr 26 12:25:30 2013
New Revision: 1476168

URL: http://svn.apache.org/r1476168
Log:
Merged revisions 1475977,1476142 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1475977 | sergeyb | 2013-04-25 22:41:19 +0100 (Thu, 25 Apr 2013) | 1 line
  
  [CXF-4988] Minor updates to support 'char' and avoid ClassCastExceptions if the filter sets
Content-Type as MediaType
........
  r1476142 | sergeyb | 2013-04-26 12:31:28 +0100 (Fri, 26 Apr 2013) | 1 line
  
  [CXF-4986] Fixing MetadataMap to enforce the read only for stores which are not copied and
all 2.0 filter contexts to set a proper flag on it; using HttpServletRequest to save the filter
properties if possible
........

Added:
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
      - copied, changed from r1476142, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java
      - copied, changed from r1476142, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java
Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractPropertiesImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1475977,1476142

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientRequestContextImpl.java
Fri Apr 26 12:25:30 2013
@@ -156,7 +156,7 @@ public class ClientRequestContextImpl ex
     public MultivaluedMap<String, Object> getHeaders() {
         h = null;
         return new MetadataMap<String, Object>(
-            (Map<String, List<Object>>)m.get(Message.PROTOCOL_HEADERS), false,
true, true);    
+            (Map<String, List<Object>>)m.get(Message.PROTOCOL_HEADERS), false,
false, true);    
 
     }
 

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientResponseContextImpl.java
Fri Apr 26 12:25:30 2013
@@ -47,7 +47,7 @@ public class ClientResponseContextImpl e
     public MultivaluedMap<String, String> getHeaders() {
         Object headers = m.get(Message.PROTOCOL_HEADERS);
         if (headers != null) {
-            return new MetadataMap<String, String>((Map<String, List<String>>)headers,
false, true, true);
+            return new MetadataMap<String, String>((Map<String, List<String>>)headers,
false, false, true);
         }
         return (MultivaluedMap<String, String>)(MultivaluedMap<?, ?>)r.getHeaders();
     }

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractPropertiesImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractPropertiesImpl.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractPropertiesImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/AbstractPropertiesImpl.java
Fri Apr 26 12:25:30 2013
@@ -19,61 +19,34 @@
 package org.apache.cxf.jaxrs.impl;
 
 import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.jaxrs.impl.PropertyHolderFactory.PropertyHolder;
 import org.apache.cxf.message.Message;
 
 public abstract class AbstractPropertiesImpl {
-
-    private static final String PROPERTY_KEY = "jaxrs.filter.properties";
-    
     protected Message m;
-    private Map<String, Object> props;
+    private PropertyHolder holder;
     public AbstractPropertiesImpl(Message message) {
+        holder = PropertyHolderFactory.getPropertyHolder(message);
         this.m = message;
-        this.props = CastUtils.cast((Map<?, ?>)message.get(PROPERTY_KEY));
     }
     
     
     public Object getProperty(String name) {
-        return props == null ? null : props.get(name);
+        return holder.getProperty(name);
     }
 
     public Enumeration<String> getPropertyNames() {
-        final Iterator<String> it = props.keySet().iterator();
-        return new Enumeration<String>() {
-
-            @Override
-            public boolean hasMoreElements() {
-                return it.hasNext();
-            }
-
-            @Override
-            public String nextElement() {
-                return it.next();
-            }
-            
-        };
+        return holder.getPropertyNames();
     }
 
 
     public void removeProperty(String name) {
-        if (props != null) {
-            props.remove(name);    
-        }
+        holder.removeProperty(name);
     }
 
 
     public void setProperty(String name, Object value) {
-        if (props == null) {
-            props = new HashMap<String, Object>();
-            m.put(PROPERTY_KEY, props);
-        }    
-        props.put(name, value);    
-        
+        holder.setProperty(name, value);
     }
 
 }

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ContainerRequestContextImpl.java
Fri Apr 26 12:25:30 2013
@@ -79,7 +79,7 @@ public class ContainerRequestContextImpl
     public MultivaluedMap<String, String> getHeaders() {
         h = null;
         return new MetadataMap<String, String>(
-            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS), false,
true, true);
+            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS), false,
false, true);
     }
 
 

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MetadataMap.java
Fri Apr 26 12:25:30 2013
@@ -35,6 +35,7 @@ import javax.ws.rs.core.MultivaluedMap;
 public class MetadataMap<K, V> implements MultivaluedMap<K, V> {
 
     private boolean caseInsensitive;
+    private boolean readOnly;
     private Map<K, List<V>> m;
     
     public MetadataMap() {
@@ -62,8 +63,7 @@ public class MetadataMap<K, V> implement
         this (store, true, readOnly, caseInsensitive);
         
     }
-    // TODO: Review the use of this constructor,
-    //       refactor the code, copyStore and readOnly are duplicates
+    
     public MetadataMap(Map<K, List<V>> store, boolean copyStore, 
                        boolean readOnly, boolean caseInsensitive) {
         
@@ -72,17 +72,17 @@ public class MetadataMap<K, V> implement
             if (store != null) {
                 for (Map.Entry<K, List<V>> entry : store.entrySet()) {
                     List<V> values = new ArrayList<V>(entry.getValue());
-                    m.put(entry.getKey(), readOnly 
-                          ? Collections.unmodifiableList(values) : values);
+                    m.put(entry.getKey(), values);
                 }
             }
-            if (readOnly) {
-                this.m = Collections.unmodifiableMap(m);
-            }
         } else {
             this.m = store;
         }
+        if (readOnly) {
+            this.m = Collections.unmodifiableMap(m);
+        }
         this.caseInsensitive = caseInsensitive;
+        this.readOnly = readOnly;
         
     }
     
@@ -105,7 +105,7 @@ public class MetadataMap<K, V> implement
             data = new ArrayList<V>();    
             m.put(key, data);
         }
-        return data;
+        return readOnly ? Collections.unmodifiableList(data) : data;
     }
     
     public V getFirst(K key) {

Copied: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
(from r1476142, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java?p2=cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java&r1=1476142&r2=1476168&rev=1476168&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/PropertyHolderFactory.java
Fri Apr 26 12:25:30 2013
@@ -18,10 +18,11 @@
  */
 package org.apache.cxf.jaxrs.impl;
 
-import java.util.Collection;
-import java.util.Collections;
+import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
+import java.util.NoSuchElementException;
 
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.message.Message;
@@ -39,7 +40,7 @@ public final class PropertyHolderFactory
         Object getProperty(String name);
         void removeProperty(String name);
         void setProperty(String name, Object value);
-        Collection<String> getPropertyNames();
+        Enumeration<String> getPropertyNames();
     }
     
     private static class MessagePropertyHolder implements PropertyHolder {
@@ -75,9 +76,23 @@ public final class PropertyHolderFactory
             
         }
 
-        public Collection<String> getPropertyNames() {
-            return props == null ? Collections.<String>emptyList() 
-                : Collections.unmodifiableSet(props.keySet());
+        public Enumeration<String> getPropertyNames() {
+            final Iterator<String> it = props != null ? props.keySet().iterator() :
null;
+            return new Enumeration<String>() {
+
+                @Override
+                public boolean hasMoreElements() {
+                    return it != null ? it.hasNext() : false;
+                }
+
+                @Override
+                public String nextElement() {
+                    if (it != null) {
+                        return it.next();
+                    }
+                    throw new NoSuchElementException();
+                }
+            };
         }
     }
 }

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ReaderInterceptorContextImpl.java
Fri Apr 26 12:25:30 2013
@@ -53,7 +53,7 @@ public class ReaderInterceptorContextImp
     @Override
     public MultivaluedMap<String, String> getHeaders() {
         return new MetadataMap<String, String>(
-            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS), false,
true, true);
+            (Map<String, List<String>>)m.get(Message.PROTOCOL_HEADERS), false,
false, true);
     }
 
     @Override

Copied: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java
(from r1476142, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java)
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java?p2=cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java&p1=cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java&r1=1476142&r2=1476168&rev=1476168&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/ServletRequestPropertyHolder.java
Fri Apr 26 12:25:30 2013
@@ -18,10 +18,8 @@
  */
 package org.apache.cxf.jaxrs.impl;
 
-import java.util.Collection;
 import java.util.Enumeration;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.Vector;
 
 import javax.servlet.http.HttpServletRequest;
 
@@ -55,8 +53,8 @@ public class ServletRequestPropertyHolde
     }
 
     @Override
-    public Collection<String> getPropertyNames() {
-        List<String> list = new LinkedList<String>(); 
+    public Enumeration<String> getPropertyNames() {
+        Vector<String> list = new Vector<String>(); 
         Enumeration<String> attrNames = request.getAttributeNames();
         while (attrNames.hasMoreElements()) {
             String name = attrNames.nextElement();
@@ -64,7 +62,7 @@ public class ServletRequestPropertyHolde
                 list.add(name);
             }
         }
-        return list;
+        return list.elements();
     }
 
 }

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/WriterInterceptorContextImpl.java
Fri Apr 26 12:25:30 2013
@@ -64,7 +64,7 @@ public class WriterInterceptorContextImp
     @Override
     public MultivaluedMap<String, Object> getHeaders() {
         return new MetadataMap<String, Object>(
-            (Map<String, List<Object>>)m.get(Message.PROTOCOL_HEADERS), false,
true, true);
+            (Map<String, List<Object>>)m.get(Message.PROTOCOL_HEADERS), false,
false, true);
     }
 
     @Override

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Fri Apr 26 12:25:30 2013
@@ -198,10 +198,10 @@ public class JAXRSOutInterceptor extends
         if (firstTry && userHeaders != null) {
             responseHeaders.putAll(userHeaders);
         }
-
-        String responseContentType = (String)message.get(Message.CONTENT_TYPE);
-        if (responseContentType != null && !responseHeaders.containsKey(HttpHeaders.CONTENT_TYPE))
{
-            responseHeaders.putSingle(HttpHeaders.CONTENT_TYPE, responseContentType);
+        
+        String initialResponseContentType = (String)message.get(Message.CONTENT_TYPE);
+        if (initialResponseContentType != null && !responseHeaders.containsKey(HttpHeaders.CONTENT_TYPE))
{
+            responseHeaders.putSingle(HttpHeaders.CONTENT_TYPE, initialResponseContentType);
         }
         
         message.put(Message.PROTOCOL_HEADERS, responseHeaders);
@@ -237,9 +237,14 @@ public class JAXRSOutInterceptor extends
             return;
         }
         
-        responseContentType = (String)responseHeaders.getFirst(HttpHeaders.CONTENT_TYPE);
-        MediaType responseMediaType = responseContentType == null ? MediaType.WILDCARD_TYPE

-            : JAXRSUtils.toMediaType(responseContentType);
+        Object mediaTypeHeader = responseHeaders.getFirst(HttpHeaders.CONTENT_TYPE);
+        MediaType responseMediaType;
+        if (mediaTypeHeader instanceof MediaType) {
+            responseMediaType = (MediaType)mediaTypeHeader;
+        } else {
+            responseMediaType = mediaTypeHeader == null ? MediaType.WILDCARD_TYPE
+                : JAXRSUtils.toMediaType(mediaTypeHeader.toString());
+        }
         
         Class<?> targetType = InjectionUtils.getRawResponseClass(entity);
         Type genericType = 
@@ -250,12 +255,12 @@ public class JAXRSOutInterceptor extends
             .createMessageBodyWriterInterceptor(targetType, genericType, annotations, responseMediaType,
message);
         
         responseMediaType = checkFinalContentType(responseMediaType);
-        responseContentType = JAXRSUtils.mediaTypeToString(responseMediaType);
+        String finalResponseContentType = JAXRSUtils.mediaTypeToString(responseMediaType);
         if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Response content type is: " + responseContentType);
+            LOG.fine("Response content type is: " + finalResponseContentType);
         }
-        responseHeaders.putSingle(HttpHeaders.CONTENT_TYPE, responseContentType);
-        message.put(Message.CONTENT_TYPE, responseContentType);
+        responseHeaders.putSingle(HttpHeaders.CONTENT_TYPE, finalResponseContentType);
+        message.put(Message.CONTENT_TYPE, finalResponseContentType);
         
         OutputStream outOriginal = message.getContent(OutputStream.class);
         if (writers == null) {

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/PrimitiveTextProvider.java
Fri Apr 26 12:25:30 2013
@@ -29,6 +29,7 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.model.ParameterType;
 import org.apache.cxf.jaxrs.utils.HttpUtils;
@@ -47,9 +48,13 @@ public class PrimitiveTextProvider<T> 
 
     public T readFrom(Class<T> type, Type genType, Annotation[] anns, MediaType mt,

                       MultivaluedMap<String, String> headers, InputStream is) throws
IOException {
-        
+        String string = IOUtils.toString(is, HttpUtils.getEncoding(mt, "UTF-8"));
+        if (type == Character.class) {
+            char character = StringUtils.isEmpty(string) ? ' ' : string.charAt(0);
+            return type.cast(Character.valueOf(character));
+        }
         return InjectionUtils.handleParameter(
-                    IOUtils.toString(is, HttpUtils.getEncoding(mt, "UTF-8")), 
+                    string, 
                     false,
                     type,
                     anns,

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MetadataMapTest.java
Fri Apr 26 12:25:30 2013
@@ -21,7 +21,12 @@ package org.apache.cxf.jaxrs.impl;
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
+
+import javax.ws.rs.core.MultivaluedMap;
 
 import org.junit.Assert;
 import org.junit.Test;
@@ -210,13 +215,59 @@ public class MetadataMapTest extends Ass
     }
     
     @Test(expected = UnsupportedOperationException.class)
-    public void testReadOnly() {
+    public void testReadOnlyRemove() {
         MetadataMap<String, Object> m = new MetadataMap<String, Object>();
         m.add("baz", "bar");
         MetadataMap<String, Object> m2 = new MetadataMap<String, Object>(m, true,
false);
         m2.remove("baz");
     }
     
+    @Test(expected = UnsupportedOperationException.class)
+    public void testReadOnlyAdd() {
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
+        m.add("baz", "bar");
+        MetadataMap<String, Object> m2 = new MetadataMap<String, Object>(m, true,
false);
+        m2.add("bar", "foo");
+    }
+    
+    @Test(expected = UnsupportedOperationException.class)
+    public void testReadOnlyAddFirst() {
+        MetadataMap<String, Object> m = new MetadataMap<String, Object>();
+        m.add("baz", "bar");
+        MetadataMap<String, Object> m2 = new MetadataMap<String, Object>(m, true,
false);
+        m2.addFirst("baz", "bar2");
+    }
+    
+    @Test(expected = UnsupportedOperationException.class)
+    public void testReadOnlyAdd2() {
+        Map<String, List<String>> values = new HashMap<String, List<String>>();
+        List<String> list = new LinkedList<String>();
+        list.add("bar");
+        values.put("baz", list);
+        MultivaluedMap<String, String> map = 
+            new MetadataMap<String, String>(values, false, true, true);
+        map.add("baz", "baz");
+    }
+    
+    @Test(expected = UnsupportedOperationException.class)
+    public void testReadOnlyAddFirst2() {
+        Map<String, List<String>> values = new HashMap<String, List<String>>();
+        List<String> list = new LinkedList<String>();
+        list.add("bar");
+        values.put("baz", list);
+        MultivaluedMap<String, String> map = 
+            new MetadataMap<String, String>(values, false, true, true);
+        map.addFirst("baz", "bar2");
+    }
+    
+    @Test(expected = UnsupportedOperationException.class)
+    public void testReadOnlyPutSingle() {
+        Map<String, List<String>> values = new HashMap<String, List<String>>();
+        MultivaluedMap<String, String> map = 
+            new MetadataMap<String, String>(values, false, true, true);
+        map.putSingle("baz", "baz");
+    }
+    
     @Test
     public void testGetCaseInsensitive() {
         MetadataMap<String, Object> m = new MetadataMap<String, Object>();

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java?rev=1476168&r1=1476167&r2=1476168&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer20.java
Fri Apr 26 12:25:30 2013
@@ -32,6 +32,7 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.BindingPriority;
 import javax.ws.rs.InternalServerErrorException;
 import javax.ws.rs.NameBinding;
@@ -140,11 +141,14 @@ public class BookServer20 extends Abstra
     @PreMatching
     @BindingPriority(3)
     private static class PreMatchContainerRequestFilter2 implements ContainerRequestFilter
{
-
+        @Context
+        private HttpServletRequest servletRequest;
         @Override
         public void filter(ContainerRequestContext context) throws IOException {
             if (!"true".equals(context.getProperty("FirstPrematchingFilter"))
-                || !"true".equals(context.getProperty("DynamicPrematchingFilter"))) {
+                || !"true".equals(context.getProperty("DynamicPrematchingFilter"))
+                || !"true".equals(servletRequest.getAttribute("FirstPrematchingFilter"))
+                || !"true".equals(servletRequest.getAttribute("DynamicPrematchingFilter")))
{
                 throw new RuntimeException();
             }
             context.getHeaders().add("BOOK", "12");



Mime
View raw message