cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r650189 - /incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
Date Mon, 21 Apr 2008 16:18:52 GMT
Author: dkulp
Date: Mon Apr 21 09:18:44 2008
New Revision: 650189

URL: http://svn.apache.org/viewvc?rev=650189&view=rev
Log:
[CXF-1535] Fix for NPE if Content-Type is null.  Patch from Alan Cabrera applied.  Thanks
Alan!

Modified:
    incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java

Modified: incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java?rev=650189&r1=650188&r2=650189&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSUtils.java
Mon Apr 21 09:18:44 2008
@@ -41,6 +41,7 @@
 import java.util.Set;
 import java.util.SortedMap;
 import java.util.TreeMap;
+import java.util.logging.Logger;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -62,8 +63,10 @@
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.MessageBodyReader;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PrimitiveUtils;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
 import org.apache.cxf.jaxrs.model.OperationResourceInfo;
@@ -80,6 +83,7 @@
 public final class JAXRSUtils {
 
     public static final MediaType ALL_TYPES = new MediaType();
+    private static final Logger LOG = LogUtils.getL7dLogger(JAXRSUtils.class);
 
     private JAXRSUtils() {        
     }
@@ -375,13 +379,19 @@
                                            Message message,
                                            OperationResourceInfo ori) {
         InputStream is = message.getContent(InputStream.class);
-        String contentType = (String)message.get(Message.CONTENT_TYPE);
-        
+
         String path = (String)message.get(JAXRSInInterceptor.RELATIVE_PATH);
         
         if ((parameterAnnotations == null || parameterAnnotations.length == 0)
             && ("PUT".equals(ori.getHttpMethod()) || "POST".equals(ori.getHttpMethod())))
{
-            return readFromMessageBody(parameterClass, 
+            String contentType = (String)message.get(Message.CONTENT_TYPE);
+
+            if (contentType == null) {
+                throw new Fault(new  org.apache.cxf.common.i18n.Message("NO_CONTENT_TYPE_SPECIFIED",
+                                                                        LOG, ori.getHttpMethod()));
+            }
+
+            return readFromMessageBody(parameterClass,
                                          is, 
                                          MediaType.parse(contentType),
                                          ori.getConsumeTypes());



Mime
View raw message